Loads location which is starting point for selecting destination content object.

@param null $defaultLocationId

@return \eZ\Publish\API\Repository\Values\Content\Location|null
9778
protected function loadDefaultLocationForSelection($defaultLocationId = null): ?Location
    {
        if (!empty($defaultLocationId)) {
            try {
                return $this->locationService->loadLocation((int)$defaultLocationId);
            } catch (NotFoundException|UnauthorizedException $e) {
            }
        }

        return null;
    }
789010
public function findDefaultByContentLocale( $contentId,
                                                $locale,
                                                $preferredSubdomainId = null )
    {
        $locale = (string) $locale;
        $priLng = Locale::getPrimaryLanguage( $locale );

        if ( $priLng != $locale )
        {
            $locale = array( $locale, $priLng );
        }

        $platform = $this->getDbAdapter()
                         ->getPlatform();

        return $this->findOne( array(
            'contentId'     => $contentId,
            'locale'        => $locale,
        ), array(
            new Expression(
                'CASE ' . $platform->quoteIdentifier( 'subdomainId' ) .
                    ' WHEN ? THEN 1 ELSE 0 END DESC',
                array( (int) $preferredSubdomainId ),
                array( Expression::TYPE_VALUE )
            ),
            'locale'    => 'DESC',
            'default'   => 'DESC',
            'id'        => 'ASC',
        ) );
    }
1222563
private function loadLocation($locationId)
    {
        $location = $this->repository->sudo(
            function (Repository $repository) use ($locationId) {
                return $repository->getLocationService()->loadLocation($locationId);
            }
        );
        if ($location->invisible) {
            throw new HiddenLocationException($location, 'Location cannot be displayed as it is flagged as invisible.');
        }

        return $location;
    }
58128
public URI getLocation() {
		String value = getFirst(LOCATION);
		return (value != null ? URI.create(value) : null);
	}
90792
public function get($locationId, array $params = array())
    {
        $endpoint = '/admin/locations/'.$locationId.'.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createObject(Location::class, $response['location']);
    }
1336982
private function isMainLocation(Location $location)
    {
        $locationContentInfo = $this->contentHandler->loadContentInfo($location->contentId);

        return $locationContentInfo->mainLocationId === $location->id;
    }
743676
public function setDefaultLocation(Location $defaultLocation)
    {
        $this->defaultLocation = $defaultLocation;
        $this->setLatitude($defaultLocation->getLatitude());
        $this->setLongitude($defaultLocation->getLongitude());
    }
1299040
public function loadLocationsForContent($contentId, Request $request)
    {
        $restLocations = array();
        $contentInfo = $this->contentService->loadContentInfo($contentId);
        foreach ($this->locationService->loadLocations($contentInfo) as $location) {
            $restLocations[] = new Values\RestLocation(
                $location,
                // @todo Remove, and make optional in VO. Not needed for a location list.
                $this->locationService->getLocationChildCount($location)
            );
        }

        return new Values\CachedValue(
            new Values\LocationList($restLocations, $request->getPathInfo()),
            array('locationId' => $contentInfo->mainLocationId)
        );
    }
720167
public function findDefaultByContentSubdomain( $contentId,
                                                   $subdomainId,
                                                   $locales = null )
    {
        return $this->getMapper()
                    ->findDefaultByContentSubdomain(
                        $contentId,
                        $subdomainId,
                        $locales
                    );
    }
1092991
public function load_routing_library( $location = null ) {
		// Set our location of our library
		$lib_location = $location ?: $this->get_config('routing')['routing_library_location'];

		// Let's first make sure that it hasn't already been loaded
		if ( !function_exists( 'respond' ) && !function_exists( 'dispatch' ) ) {
			require_once( $lib_location );
		}
	}
675488
public function loadTrashByLocation($locationId)
    {
        try {
            return $this->innerGateway->loadTrashByLocation($locationId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
102823
public function DefaultLocation()
    {
        $location = $this
            ->Locations()
            ->sort("Default", "DESC")
            ->first();
        
        $this->extend("updateDefaultLocation", $location);

        return $location;
    }
700401
private function getMenuItems($rootLocationId)
    {
        $rootLocation = $this->locationService->loadLocation($rootLocationId);

        $query = new LocationQuery();

        $query->query = new Criterion\LogicalAnd(
            array(
                new Criterion\ContentTypeIdentifier($this->getTopMenuContentTypeIdentifierList()),
                new Criterion\Visibility(Criterion\Visibility::VISIBLE),
                new Criterion\Location\Depth(
                    Criterion\Operator::BETWEEN,
                    array($rootLocation->depth + 1, $rootLocation->depth + 2)
                ),
                new Criterion\Subtree($rootLocation->pathString),
                new Criterion\LanguageCode($this->configResolver->getParameter('languages')),
            )
        );
        $query->sortClauses = array(new Query\SortClause\Location\Path());
        $query->performCount = false;

        return $this->searchService->findLocations($query)->searchHits;
    }
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;
    }
996766
public function getPath($locationId, array $options = []): array
    {
        $optionsResolver = new OptionsResolver();
        $this->configureOptions($optionsResolver);
        $options = $optionsResolver->resolve($options);

        $excludedContentTypes = [];
        if (
            !$options['use_all_content_types'] &&
            $this->configResolver->hasParameter('path_helper.excluded_content_types', 'ngsite')
        ) {
            $excludedContentTypes = $this->configResolver->getParameter('path_helper.excluded_content_types', 'ngsite');
            if (!is_array($excludedContentTypes)) {
                $excludedContentTypes = [];
            }
        }

        // The root location can be defined at site access level
        $rootLocationId = (int) $this->configResolver->getParameter('content.tree_root.location_id');

        $path = $this->loadService->loadLocation($locationId)->path;

        // Shift of location "1" from path as it is not a fully valid location and not readable by most users
        array_shift($path);

        $pathArray = [];
        $rootLocationFound = false;
        foreach ($path as $index => $pathItem) {
            if ((int) $pathItem === $rootLocationId) {
                $rootLocationFound = true;
            }

            if (!$rootLocationFound) {
                continue;
            }

            try {
                $location = $this->loadService->loadLocation($pathItem);
            } catch (UnauthorizedException $e) {
                return [];
            }

            if (!in_array($location->contentInfo->contentTypeIdentifier, $excludedContentTypes, true)) {
                $pathArray[] = [
                    'text' => $location->contentInfo->name,
                    'url' => $location->id !== (int) $locationId ?
                        $this->router->generate(
                            $location,
                            [],
                            $options['absolute_url'] ?
                                UrlGeneratorInterface::ABSOLUTE_URL :
                                UrlGeneratorInterface::ABSOLUTE_PATH
                        ) :
                        false,
                    'location' => $location,
                ];
            }
        }

        return $pathArray;
    }
963961
public function load(Location $location): self
    {
        $customUrlAliases = $this->urlAliasService->listLocationAliases($location, true, null, true);
        $this->data = array_map(
            function (URLAlias $urlAlias) {
                return $this->valueFactory->createUrlAlias($urlAlias);
            },
            $customUrlAliases
        );

        return $this;
    }
1018194
public function locationCopied($locationId, $newLocationId, $newParentId)
    {
        $newParentAliasId = $this->getRealAliasId($newLocationId);
        $oldParentAliasId = $this->getRealAliasId($locationId);

        $actionMap = $this->getCopiedLocationsMap($locationId, $newLocationId);

        $this->copySubtree(
            $actionMap,
            $oldParentAliasId,
            $newParentAliasId
        );
    }