Code Duplication    Length = 20-20 lines in 3 locations

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

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