Code Duplication    Length = 20-20 lines in 3 locations

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

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