Code Duplication    Length = 20-20 lines in 3 locations

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

@@ 146-165 (lines=20) @@
143
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
144
         */
145
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion();
146
        if ($contentReadCriterion === false) {
147
            throw new UnauthorizedException('content', 'read');
148
        } elseif ($contentReadCriterion !== true) {
149
            // Query if there are any content in subtree current user don't have access to
150
            $query = new Query(
151
                array(
152
                    'limit' => 0,
153
                    'filter' => new CriterionLogicalAnd(
154
                        array(
155
                            new CriterionSubtree($loadedSubtree->pathString),
156
                            new CriterionLogicalNot($contentReadCriterion),
157
                        )
158
                    ),
159
                )
160
            );
161
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
162
            if ($result->totalCount > 0) {
163
                throw new UnauthorizedException('content', 'read');
164
            }
165
        }
166
167
        $this->repository->beginTransaction();
168
        try {
@@ 686-705 (lines=20) @@
683
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
684
         */
685
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion();
686
        if ($contentReadCriterion === false) {
687
            throw new UnauthorizedException('content', 'read');
688
        } elseif ($contentReadCriterion !== true) {
689
            // Query if there are any content in subtree current user don't have access to
690
            $query = new Query(
691
                array(
692
                    'limit' => 0,
693
                    'filter' => new CriterionLogicalAnd(
694
                        array(
695
                            new CriterionSubtree($location->pathString),
696
                            new CriterionLogicalNot($contentReadCriterion),
697
                        )
698
                    ),
699
                )
700
            );
701
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
702
            if ($result->totalCount > 0) {
703
                throw new UnauthorizedException('content', 'read');
704
            }
705
        }
706
707
        if (strpos($newParentLocation->pathString, $location->pathString) === 0) {
708
            throw new InvalidArgumentException(
@@ 765-784 (lines=20) @@
762
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
763
         */
764
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
765
        if ($contentReadCriterion === false) {
766
            throw new UnauthorizedException('content', 'remove');
767
        } elseif ($contentReadCriterion !== true) {
768
            // Query if there are any content in subtree current user don't have access to
769
            $query = new Query(
770
                array(
771
                    'limit' => 0,
772
                    'filter' => new CriterionLogicalAnd(
773
                        array(
774
                            new CriterionSubtree($location->pathString),
775
                            new CriterionLogicalNot($contentReadCriterion),
776
                        )
777
                    ),
778
                )
779
            );
780
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
781
            if ($result->totalCount > 0) {
782
                throw new UnauthorizedException('content', 'remove');
783
            }
784
        }
785
786
        $this->repository->beginTransaction();
787
        try {