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();
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
                array(
139
                    'limit' => 0,
140
                    'filter' => new CriterionLogicalAnd(
141
                        array(
142
                            new CriterionSubtree($loadedSubtree->pathString),
143
                            new CriterionLogicalNot($contentReadCriterion),
144
                        )
145
                    ),
146
                )
147
            );
148
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
149
            if ($result->totalCount > 0) {
150
                throw new UnauthorizedException('content', 'read');
151
            }
152
        }
153
154
        $this->repository->beginTransaction();
155
        try {
@@ 627-646 (lines=20) @@
624
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
625
         */
626
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion();
627
        if ($contentReadCriterion === false) {
628
            throw new UnauthorizedException('content', 'read');
629
        } elseif ($contentReadCriterion !== true) {
630
            // Query if there are any content in subtree current user don't have access to
631
            $query = new Query(
632
                array(
633
                    'limit' => 0,
634
                    'filter' => new CriterionLogicalAnd(
635
                        array(
636
                            new CriterionSubtree($location->pathString),
637
                            new CriterionLogicalNot($contentReadCriterion),
638
                        )
639
                    ),
640
                )
641
            );
642
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
643
            if ($result->totalCount > 0) {
644
                throw new UnauthorizedException('content', 'read');
645
            }
646
        }
647
648
        if (strpos($newParentLocation->pathString, $location->pathString) === 0) {
649
            throw new InvalidArgumentException(
@@ 706-725 (lines=20) @@
703
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
704
         */
705
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
706
        if ($contentReadCriterion === false) {
707
            throw new UnauthorizedException('content', 'remove');
708
        } elseif ($contentReadCriterion !== true) {
709
            // Query if there are any content in subtree current user don't have access to
710
            $query = new Query(
711
                array(
712
                    'limit' => 0,
713
                    'filter' => new CriterionLogicalAnd(
714
                        array(
715
                            new CriterionSubtree($location->pathString),
716
                            new CriterionLogicalNot($contentReadCriterion),
717
                        )
718
                    ),
719
                )
720
            );
721
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
722
            if ($result->totalCount > 0) {
723
                throw new UnauthorizedException('content', 'remove');
724
            }
725
        }
726
727
        $this->repository->beginTransaction();
728
        try {