Code Duplication    Length = 20-20 lines in 3 locations

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

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