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 {
@@ 691-710 (lines=20) @@
688
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
689
         */
690
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'read');
691
        if ($contentReadCriterion === false) {
692
            throw new UnauthorizedException('content', 'read');
693
        } elseif ($contentReadCriterion !== true) {
694
            // Query if there are any content in subtree current user don't have access to
695
            $query = new Query(
696
                [
697
                    'limit' => 0,
698
                    'filter' => new CriterionLogicalAnd(
699
                        [
700
                            new CriterionSubtree($location->pathString),
701
                            new CriterionLogicalNot($contentReadCriterion),
702
                        ]
703
                    ),
704
                ]
705
            );
706
            $result = $this->repository->getSearchService()->findContent($query, [], false);
707
            if ($result->totalCount > 0) {
708
                throw new UnauthorizedException('content', 'read');
709
            }
710
        }
711
712
        $this->repository->beginTransaction();
713
        try {
@@ 761-780 (lines=20) @@
758
759
        // Check remove access to descendants
760
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
761
        if ($contentReadCriterion === false) {
762
            throw new UnauthorizedException('content', 'remove');
763
        } elseif ($contentReadCriterion !== true) {
764
            // Query if there are any content in subtree current user don't have access to
765
            $query = new Query(
766
                [
767
                    'limit' => 0,
768
                    'filter' => new CriterionLogicalAnd(
769
                        [
770
                            new CriterionSubtree($location->pathString),
771
                            new CriterionLogicalNot($contentReadCriterion),
772
                        ]
773
                    ),
774
                ]
775
            );
776
            $result = $this->repository->getSearchService()->findContent($query, [], false);
777
            if ($result->totalCount > 0) {
778
                throw new UnauthorizedException('content', 'remove');
779
            }
780
        }
781
782
        $this->repository->beginTransaction();
783
        try {