Code Duplication    Length = 20-20 lines in 3 locations

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

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