Code Duplication    Length = 20-20 lines in 3 locations

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

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