Copied!

LocationService

LocationService.php : 22

Location service, used for complex subtree operations.

Methods

publiccopySubtree()

LocationService.php : 38

Copies the subtree starting from $subtree as a new subtree of $targetLocation.

public copySubtree(Location $subtree, Location $targetParentLocation) : Location

Only the items on which the user has read access are copied.

Parameters

Name Type Default value Description
$subtree Location -

the subtree denoted by the location to copy

$targetParentLocation Location -

the target parent location for the copy operation

Return values

Location

The newly created location of the copied subtree

Tags
Throws
UnauthorizedException

If the current user user is not allowed copy the subtree to the given parent location

Throws
UnauthorizedException

If the current user user does not have read access to the whole source subtree

Throws
InvalidArgumentException

if the target location is a sub location of the given location

publiccount()

LocationService.php : 276

Count total number of items returned by {@see find} method.

public count(Filter $filter[, array<string|int, string> $languages = null ]) : int

Parameters

Name Type Default value Description
$filter Filter - -
$languages array<string|int, string> null

a list of language codes to be added as additional constraints. If skipped, by default, unless SiteAccessAware layer has been disabled, languages set for a SiteAccess in a current context will be used.

Return values

int

publiccreateLocation()

LocationService.php : 149

Creates the new $location in the content repository for the given content.

public createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct) : Location

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$locationCreateStruct LocationCreateStruct - -

Return values

Location

the newly created Location

Tags
Throws
UnauthorizedException

If the current user user is not allowed to create this location

Throws
InvalidArgumentException

if the content is already below the specified parent or the parent is a sub location of the location of the content or if set the remoteId exists already

publicdeleteLocation()

LocationService.php : 223

Deletes $location and all its descendants.

public deleteLocation(Location $location) : void

Parameters

Name Type Default value Description
$location Location - -
Tags
Throws
UnauthorizedException

If the current user is not allowed to delete this location or a descendant

publicfind()

LocationService.php : 267

Fetch a LocationList from the Repository filtered by the given conditions.

public find(Filter $filter[, array<string|int, string> $languages = null ]) : LocationList

Parameters

Name Type Default value Description
$filter Filter - -
$languages array<string|int, string> null

a list of language codes to be added as additional constraints. If skipped, by default, unless SiteAccessAware layer has been disabled, languages set for a SiteAccess in a current context will be used.

Return values

LocationList

publicgetAllLocationsCount()

LocationService.php : 248

Get the total number of all existing Locations. Can be combined with loadAllLocations.

public getAllLocationsCount() : int

Return values

int

Total number of Locations

publicgetLocationChildCount()

LocationService.php : 127

Returns the number of children which are readable by the current user of a location object.

public getLocationChildCount(Location $location) : int

Parameters

Name Type Default value Description
$location Location - -

Return values

int

publicgetSubtreeSize()

LocationService.php : 134

Return the subtree size of a given location.

public getSubtreeSize(Location $location) : int

Warning! This method is not permission aware by design.

Parameters

Name Type Default value Description
$location Location - -

Return values

int

publichideLocation()

LocationService.php : 183

Hides the $location and marks invisible all descendants of $location.

public hideLocation(Location $location) : Location

Parameters

Name Type Default value Description
$location Location - -

Return values

Location

$location, with updated hidden value

Tags
Throws
UnauthorizedException

If the current user user is not allowed to hide this location

publicloadAllLocations()

LocationService.php : 258

Bulk-load all existing Locations, constrained by $limit and $offset to paginate results.

public loadAllLocations([int $offset = 0 ][, int $limit = 25 ]) : array<string|int, Location>

Parameters

Name Type Default value Description
$offset int 0 -
$limit int 25 -

Return values

array<string|int, Location>

publicloadLocation()

LocationService.php : 52

Loads a location object from its $locationId.

public loadLocation(mixed $locationId[, array<string|int, string>|null $prioritizedLanguages = null ][, bool|null $useAlwaysAvailable = null ]) : Location

Parameters

Name Type Default value Description
$locationId mixed - -
$prioritizedLanguages array<string|int, string>|null null

Filter on and use as prioritized language code on translated properties of returned object.

$useAlwaysAvailable bool|null null

Respect always available flag on content when filtering on $prioritizedLanguages.

Return values

Location

Tags
Throws
UnauthorizedException

If the current user user is not allowed to read this location

Throws
NotFoundException

If the specified location is not found

publicloadLocationByRemoteId()

LocationService.php : 79

Loads a location object from its $remoteId.

public loadLocationByRemoteId(string $remoteId[, array<string|int, string>|null $prioritizedLanguages = null ][, bool|null $useAlwaysAvailable = null ]) : Location

Parameters

Name Type Default value Description
$remoteId string - -
$prioritizedLanguages array<string|int, string>|null null

Filter on and use as prioritized language code on translated properties of returned object.

$useAlwaysAvailable bool|null null

Respect always available flag on content when filtering on $prioritizedLanguages.

Return values

Location

Tags
Throws
UnauthorizedException

If the current user user is not allowed to read this location

Throws
NotFoundException

If the specified location is not found

publicloadLocationChildren()

LocationService.php : 108

Loads children which are readable by the current user of a location object sorted by sortField and sortOrder.

public loadLocationChildren(Location $location[, int $offset = 0 ][, int $limit = 25 ][, array<string|int, string>|null $prioritizedLanguages = null ]) : LocationList

Use this method with caution. It performs heavy queries on the database. Consider using SearchService::findLocations() with ChildrenQueryType as an alternative.

Parameters

Name Type Default value Description
$location Location - -
$offset int 0

the start offset for paging

$limit int 25

the number of locations returned

$prioritizedLanguages array<string|int, string>|null null

Used as prioritized language code on translated properties of returned object.

Return values

LocationList

publicloadLocationList()

LocationService.php : 65

Loads several location objects from its $locationIds.

public loadLocationList(array<string|int, mixed> $locationIds[, array<string|int, string>|null $prioritizedLanguages = null ][, bool|null $useAlwaysAvailable = null ]) : array<string|int, Location>|iterable<string|int, mixed>

Returned list of Locations will be filtered by what is found and what current user has access to.

Parameters

Name Type Default value Description
$locationIds array<string|int, mixed> - -
$prioritizedLanguages array<string|int, string>|null null

Filter on and use as prioritized language code on translated properties of returned objects.

$useAlwaysAvailable bool|null null

Respect always available flag on content when filtering on $prioritizedLanguages.

Return values

array<string|int, Location>|iterable<string|int, mixed>

publicloadLocations()

LocationService.php : 95

Loads the locations for the given content object.

public loadLocations(ContentInfo $contentInfo[, Location $rootLocation = null ][, array<string|int, string>|null $prioritizedLanguages = null ]) : array<string|int, Location>

If a $rootLocation is given, only locations that belong to this location are returned. The location list is also filtered by permissions on reading locations.

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$rootLocation Location null -
$prioritizedLanguages array<string|int, string>|null null

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, Location>

An array of Location

Tags
Throws
BadStateException

if there is no published version yet

publicloadParentLocationsForDraftContent()

LocationService.php : 118

Load parent Locations for Content Draft.

public loadParentLocationsForDraftContent(VersionInfo $versionInfo[, array<string|int, string>|null $prioritizedLanguages = null ]) : array<string|int, Location>

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -
$prioritizedLanguages array<string|int, string>|null null

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, Location>

List of parent Locations

publicmoveSubtree()

LocationService.php : 214

Moves the subtree to $newParentLocation.

public moveSubtree(Location $location, Location $newParentLocation) : void

If a user has the permission to move the location to a target location he can do it regardless of an existing descendant on which the user has no permission.

Parameters

Name Type Default value Description
$location Location - -
$newParentLocation Location - -
Tags
Throws
UnauthorizedException

If the current user user is not allowed to move this location to the target

Throws
UnauthorizedException

If the current user user does not have read access to the whole source subtree

Throws
InvalidArgumentException

if the new parent is in a subtree of the location

Throws
InvalidArgumentException

if the new parent location is the same as current

Throws
InvalidArgumentException

if the new parent location is not a container

publicnewLocationCreateStruct()

LocationService.php : 232

Instantiates a new location create class.

public newLocationCreateStruct(mixed $parentLocationId) : LocationCreateStruct

Parameters

Name Type Default value Description
$parentLocationId mixed -

the parent under which the new location should be created

Return values

LocationCreateStruct

publicnewLocationUpdateStruct()

LocationService.php : 239

Instantiates a new location update class.

public newLocationUpdateStruct() : LocationUpdateStruct

Return values

LocationUpdateStruct

publicswapLocation()

LocationService.php : 172

Swaps the contents held by $location1 and $location2.

public swapLocation(Location $location1, Location $location2) : void

Parameters

Name Type Default value Description
$location1 Location - -
$location2 Location - -
Tags
Throws
UnauthorizedException

If the current user user is not allowed to swap content

publicunhideLocation()

LocationService.php : 197

Unhides the $location.

public unhideLocation(Location $location) : Location

This method and marks visible all descendants of $locations until a hidden location is found.

Parameters

Name Type Default value Description
$location Location - -

Return values

Location

$location, with updated hidden value

Tags
Throws
UnauthorizedException

If the current user user is not allowed to unhide this location

publicupdateLocation()

LocationService.php : 162

Updates $location in the content repository.

public updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct) : Location

Parameters

Name Type Default value Description
$location Location - -
$locationUpdateStruct LocationUpdateStruct - -

Return values

Location

the updated Location

Tags
Throws
UnauthorizedException

If the current user user is not allowed to update this location

Throws
InvalidArgumentException

if if set the remoteId exists already