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