public function assignSectionToSubtree(Location $location, Section $section): void
    {
        $loadedSubtree = $this->repository->getLocationService()->loadLocation($location->id);
        $loadedSection = $this->loadSection($section->id);

        /**
         * Check read access to whole source subtree.
         *
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
         */
        $sectionAssignCriterion = $this->permissionCriterionResolver->getPermissionsCriterion(
            'section', 'assign', [$loadedSection]
        );
        if ($sectionAssignCriterion === false) {
            throw new UnauthorizedException('section', 'assign', [
                'name' => $loadedSection->name,
                'subtree' => $loadedSubtree->pathString,
            ]);
        } elseif ($sectionAssignCriterion !== true) {
            // Query if there are any content in subtree current user don't have access to
            $query = new Query(
                [
                    'limit' => 0,
                    'filter' => new CriterionLogicalAnd(
                        [
                            new CriterionSubtree($loadedSubtree->pathString),
                            new CriterionLogicalNot($sectionAssignCriterion),
                        ]
                    ),
                ]
            );

            $result = $this->repository->getSearchService()->findContent($query, [], false);
            if ($result->totalCount > 0) {
                throw new UnauthorizedException('section', 'assign', [
                    'name' => $loadedSection->name,
                    'subtree' => $loadedSubtree->pathString,
                ]);
            }
        }

        $this->repository->beginTransaction();
        try {
            $this->locationHandler->setSectionForSubtree(
                $loadedSubtree->id,
                $loadedSection->id
            );
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }