Deletes $location and all its descendants.

@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this location or a descendant

@param \eZ\Publish\API\Repository\Values\Content\Location $location
335644
public function deleteLocation(APILocation $location)
    {
        $location = $this->loadLocation($location->id);

        if (!$this->repository->canUser('content', 'manage_locations', $location->getContentInfo())) {
            throw new UnauthorizedException('content', 'manage_locations', ['locationId' => $location->id]);
        }
        if (!$this->repository->canUser('content', 'remove', $location->getContentInfo(), $location)) {
            throw new UnauthorizedException('content', 'remove', ['locationId' => $location->id]);
        }

        /** Check remove access to descendants
         * @var bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion
         */
        $contentReadCriterion = $this->permissionCriterionResolver->getPermissionsCriterion('content', 'remove');
        if ($contentReadCriterion === false) {
            throw new UnauthorizedException('content', 'remove');
        } elseif ($contentReadCriterion !== true) {
            // Query if there are any content in subtree current user don't have access to
            $query = new Query(
                array(
                    'limit' => 0,
                    'filter' => new CriterionLogicalAnd(
                        array(
                            new CriterionSubtree($location->pathString),
                            new CriterionLogicalNot($contentReadCriterion),
                        )
                    ),
                )
            );
            $result = $this->repository->getSearchService()->findContent($query, array(), false);
            if ($result->totalCount > 0) {
                throw new UnauthorizedException('content', 'remove');
            }
        }

        $this->repository->beginTransaction();
        try {
            $this->persistenceHandler->locationHandler()->removeSubtree($location->id);
            $this->persistenceHandler->urlAliasHandler()->locationDeleted($location->id);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }
531021
public function matchLocation(Location $location)
    {
        $contentType = $this->repository
            ->getContentTypeService()
            ->loadContentType($location->getContentInfo()->contentTypeId);

        return isset($this->values[$contentType->identifier]);
    }
609461
public function updateLocation(Location $location, $andFlush = true)
    {
        $this->objectManager->persist($location);
        if ($andFlush) {
            $this->objectManager->flush();
        }
    }
1108686
public function set($name, Location $location)
    {
        return $this->cache->put($name, $location->toArray(), $this->expires);
    }
534877
public function removeLocation($locationId)
    {
        $query = $this->handler->createDeleteQuery();
        $query->deleteFrom(
            'ezcontentobject_tree'
        )->where(
            $query->expr->eq(
                $this->handler->quoteColumn('node_id'),
                $query->bindValue($locationId, null, \PDO::PARAM_INT)
            )
        );
        $query->prepare()->execute();
    }
462954
private function canRead(ContentInfo $contentInfo, Location $location = null)
    {
        $limitations = ['valueObject' => $contentInfo];
        if (isset($location)) {
            $limitations['targets'] = $location;
        }

        $readAttribute = new AuthorizationAttribute('content', 'read', $limitations);
        $viewEmbedAttribute = new AuthorizationAttribute('content', 'view_embed', $limitations);

        return
            $this->authorizationChecker->isGranted($readAttribute) ||
            $this->authorizationChecker->isGranted($viewEmbedAttribute);
    }
506755
public function deletePermission(string $action): void
    {
        /** @var HCAclPermission $permission */
        $permission = $this->findOneBy(['action' => $action]);

        $permission->roles()->detach();

        $permission->forceDelete();
    }
1336982
private function isMainLocation(Location $location)
    {
        $locationContentInfo = $this->contentHandler->loadContentInfo($location->contentId);

        return $locationContentInfo->mainLocationId === $location->id;
    }
1131616
public function mapLocation(Location $location)
    {
        $contentInfo = $this->contentHandler->loadContentInfo($location->contentId);
        $content = $this->contentHandler->load($location->contentId, $contentInfo->currentVersionNo);
        $section = $this->sectionHandler->load($content->versionInfo->contentInfo->sectionId);

        $document = $this->mapContentLocation($location, $content);
        $document->id = $location->id;
        $document->type = 'location';

        $document->fields[] = new Field(
            'is_main_location',
            ($location->id == $content->versionInfo->contentInfo->mainLocationId),
            new FieldType\BooleanField()
        );

        // UserGroups and Users are Content, but permissions cascade is achieved through
        // Locations hierarchy. We index all ancestor Location Content ids of all
        // Locations of an owner.
        $ancestorLocationsContentIds = $this->getAncestorLocationsContentIds($contentInfo->ownerId);
        // Add owner user id as it can also be considered as user group.
        $ancestorLocationsContentIds[] = $contentInfo->ownerId;
        $document->fields[] = new Field(
            'content_owner_user_group',
            $ancestorLocationsContentIds,
            new FieldType\MultipleIdentifierField()
        );

        $document->fields[] = new Field(
            'content_id',
            $content->versionInfo->contentInfo->id,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_type',
            $content->versionInfo->contentInfo->contentTypeId,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_version',
            $content->versionInfo->versionNo,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_status',
            $content->versionInfo->status,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_name',
            $content->versionInfo->contentInfo->name,
            new FieldType\StringField()
        );
        $document->fields[] = new Field(
            'content_creator',
            $content->versionInfo->creatorId,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_owner',
            $content->versionInfo->contentInfo->ownerId,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_section',
            $content->versionInfo->contentInfo->sectionId,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_section_identifier',
            $section->identifier,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_section_name',
            $section->name,
            new FieldType\StringField()
        );
        $document->fields[] = new Field(
            'content_remote_id',
            $content->versionInfo->contentInfo->remoteId,
            new FieldType\IdentifierField()
        );
        $document->fields[] = new Field(
            'content_modified',
            $content->versionInfo->contentInfo->modificationDate,
            new FieldType\DateField()
        );
        $document->fields[] = new Field(
            'content_published',
            $content->versionInfo->contentInfo->publicationDate,
            new FieldType\DateField()
        );
        $document->fields[] = new Field(
            'content_language_code',
            array_keys($content->versionInfo->names),
            new FieldType\MultipleStringField()
        );
        $document->fields[] = new Field(
            'content_always_available',
            $content->versionInfo->contentInfo->alwaysAvailable,
            new FieldType\BooleanField()
        );

        $contentType = $this->contentTypeHandler->load($content->versionInfo->contentInfo->contentTypeId);
        $document->fields[] = new Field(
            'content_group',
            $contentType->groupIds,
            new FieldType\MultipleIdentifierField()
        );

        $document->fields[] = new Field(
            'content_object_state',
            $this->getObjectStateIds($content->versionInfo->contentInfo->id),
            new FieldType\MultipleIdentifierField()
        );

        return $document;
    }
1303385
public function locationDeleted($locationId)
    {
        $action = 'eznode:' . $locationId;
        $entry = $this->gateway->loadAutogeneratedEntry($action);

        $this->removeSubtree($entry['id'], $action, $entry['is_original']);
    }
775258
public function redirect($location, $status = 302)
    {
        if (!$location) {
            return;
        }
        $this->status($status);
        $headers = $this->headers();
        $headers['Location'] = $location;
        return $this;
    }
829868
private function updateSubtreeSectionIfNecessary(Location $location, $sectionId)
    {
        if ($this->isMainLocation($location)) {
            $this->setSectionForSubtree($location->id, $sectionId);
        }
    }
912770
public function addLocation(Location $location)
    {
        $this->locations->add($location);

        unset( $this->viewPathCache );
        $this->viewPathCache = [];

        return $this;
    }
238597
public function redirect($location, $isPermanently = false)
    {
        if ($isPermanently) {
            header('Location: ' . $location, false, 301);
            exit;
        } else {
            header('Location: ' . $location, false, 302);
            exit;
        }
    }
279746
public function listPlaceListAction(Location $location)
    {
        /** @var \EzSystems\DemoBundle\Helper\PlaceHelper $placeHelper */
        $placeHelper = $this->get('ezdemo.place_helper');

        $places = $placeHelper->getPlaceList(
            $location,
            $this->container->getParameter('ezdemo.places.place_list.content_types'),
            $this->getConfigResolver()->getParameter('languages')
        );

        return $this->render(
            'eZDemoBundle:parts/place:place_list.html.twig',
            array('places' => $places)
        );
    }
634039
public function matchLocation(APILocation $location)
    {
        $parent = $this->repository->sudo(
            function (Repository $repository) use ($location) {
                return $repository->getLocationService()->loadLocation($location->parentLocationId);
            }
        );

        return isset($this->values[$parent->getContentInfo()->contentTypeId]);
    }
1334680
protected function getConfig(Location $location)
    {
        $contentTypeConfig = $this->getConfigForContentType(
            $this->getContentType($location)
        );

        return array_replace($this->config, $contentTypeConfig);
    }