LocationService
Location service, used for complex subtree operations.
Methods¶
copySubtree()
¶
Copies the subtree starting from $subtree as a new subtree of $targetLocation.
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
The newly created location of the copied subtree
Tags
count()
¶
Count total number of items returned by {@see find} method.
|
|
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
createLocation()
¶
Creates the new $location in the content repository for the given content.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentInfo | ContentInfo | - | - |
$locationCreateStruct | LocationCreateStruct | - | - |
Return values
the newly created Location
Tags
deleteLocation()
¶
Deletes $location and all its descendants.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location | Location | - | - |
Tags
find()
¶
Fetch a LocationList from the Repository filtered by the given conditions.
|
|
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
getAllLocationsCount()
¶
Get the total number of all existing Locations. Can be combined with loadAllLocations.
|
|
Return values
int
Total number of Locations
getLocationChildCount()
¶
Returns the number of children which are readable by the current user of a location object.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location | Location | - | - |
Return values
int
getSubtreeSize()
¶
Return the subtree size of a given location.
|
|
Warning! This method is not permission aware by design.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location | Location | - | - |
Return values
int
hideLocation()
¶
Hides the $location and marks invisible all descendants of $location.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location | Location | - | - |
Return values
$location, with updated hidden value
Tags
loadAllLocations()
¶
Bulk-load all existing Locations, constrained by $limit and $offset to paginate results.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$offset | int | 0 | - |
$limit | int | 25 | - |
Return values
array<string|int, Location>
loadLocation()
¶
Loads a location object from its $locationId.
|
|
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
Tags
loadLocationByRemoteId()
¶
Loads a location object from its $remoteId.
|
|
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
Tags
loadLocationChildren()
¶
Loads children which are readable by the current user of a location object sorted by sortField and sortOrder.
|
|
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
loadLocationList()
¶
Loads several location objects from its $locationIds.
|
|
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>
loadLocations()
¶
Loads the locations for the given content object.
|
|
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
loadParentLocationsForDraftContent()
¶
Load parent Locations for Content Draft.
|
|
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
moveSubtree()
¶
Moves the subtree to $newParentLocation.
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
newLocationCreateStruct()
¶
Instantiates a new location create class.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$parentLocationId | mixed | - |
the parent under which the new location should be created |
Return values
newLocationUpdateStruct()
¶
Instantiates a new location update class.
|
|
Return values
swapLocation()
¶
Swaps the contents held by $location1 and $location2.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location1 | Location | - | - |
$location2 | Location | - | - |
Tags
unhideLocation()
¶
Unhides the $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, with updated hidden value
Tags
updateLocation()
¶
Updates $location in the content repository.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$location | Location | - | - |
$locationUpdateStruct | LocationUpdateStruct | - | - |
Return values
the updated Location