Code Duplication    Length = 20-20 lines in 3 locations

eZ/Publish/Core/Repository/LocationService.php 3 locations

@@ 131-150 (lines=20) @@
128
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
129
         */
130
        $contentReadCriterion = $this->permissionsCriterionHandler->getPermissionsCriterion();
131
        if ($contentReadCriterion === false) {
132
            throw new UnauthorizedException('content', 'read');
133
        } elseif ($contentReadCriterion !== true) {
134
            // Query if there are any content in subtree current user don't have access to
135
            $query = new Query(
136
                array(
137
                    'limit' => 0,
138
                    'filter' => new CriterionLogicalAnd(
139
                        array(
140
                            new CriterionSubtree($loadedSubtree->pathString),
141
                            new CriterionLogicalNot($contentReadCriterion),
142
                        )
143
                    ),
144
                )
145
            );
146
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
147
            if ($result->totalCount > 0) {
148
                throw new UnauthorizedException('content', 'read');
149
            }
150
        }
151
152
        $this->repository->beginTransaction();
153
        try {
@@ 603-622 (lines=20) @@
600
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
601
         */
602
        $contentReadCriterion = $this->permissionsCriterionHandler->getPermissionsCriterion();
603
        if ($contentReadCriterion === false) {
604
            throw new UnauthorizedException('content', 'read');
605
        } elseif ($contentReadCriterion !== true) {
606
            // Query if there are any content in subtree current user don't have access to
607
            $query = new Query(
608
                array(
609
                    'limit' => 0,
610
                    'filter' => new CriterionLogicalAnd(
611
                        array(
612
                            new CriterionSubtree($location->pathString),
613
                            new CriterionLogicalNot($contentReadCriterion),
614
                        )
615
                    ),
616
                )
617
            );
618
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
619
            if ($result->totalCount > 0) {
620
                throw new UnauthorizedException('content', 'read');
621
            }
622
        }
623
624
        if (strpos($newParentLocation->pathString, $location->pathString) === 0) {
625
            throw new InvalidArgumentException(
@@ 682-701 (lines=20) @@
679
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
680
         */
681
        $contentReadCriterion = $this->permissionsCriterionHandler->getPermissionsCriterion('content', 'remove');
682
        if ($contentReadCriterion === false) {
683
            throw new UnauthorizedException('content', 'remove');
684
        } elseif ($contentReadCriterion !== true) {
685
            // Query if there are any content in subtree current user don't have access to
686
            $query = new Query(
687
                array(
688
                    'limit' => 0,
689
                    'filter' => new CriterionLogicalAnd(
690
                        array(
691
                            new CriterionSubtree($location->pathString),
692
                            new CriterionLogicalNot($contentReadCriterion),
693
                        )
694
                    ),
695
                )
696
            );
697
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
698
            if ($result->totalCount > 0) {
699
                throw new UnauthorizedException('content', 'remove');
700
            }
701
        }
702
703
        $this->repository->beginTransaction();
704
        try {