Class

eZ\Publish\Core\REST\Client\LocationService

class LocationService implements LocationService, Sessionable

Location service, used for complex subtree operations.

Methods

__construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser)

setSession(mixed $id)

Set session ID.

LocationCreateStruct newLocationCreateStruct(mixed $parentLocationId)

Instantiates a new location create class.

Location createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct)

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

Location loadLocation(mixed $locationId)

Loads a location object from its $locationId.

Location loadLocationByRemoteId(string $remoteId)

Loads a location object from its $remoteId.

LocationUpdateStruct newLocationUpdateStruct()

Instantiates a new location update class.

Location updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct)

Updates $location in the content repository.

Location[] loadLocations(ContentInfo $contentInfo, Location $rootLocation = null)

Loads the locations for the given content object.

LocationList loadLocationChildren(Location $location, int $offset, int $limit = 25)

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

int getLocationChildCount(Location $location)

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

swapLocation(Location $location1, Location $location2)

Swaps the contents hold by the $location1 and $location2.

Location hideLocation(Location $location)

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

Location unhideLocation(Location $location)

Unhides the $location.

deleteLocation(Location $location)

Deletes $location and all its descendants.

Location copySubtree(Location $subtree, Location $targetParentLocation)

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

moveSubtree(Location $location, Location $newParentLocation)

Moves the subtree to $newParentLocation.

Details

at line 55
public __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser)

Parameters

HttpClient $client
Dispatcher $inputDispatcher
Visitor $outputVisitor
RequestParser $requestParser

at line 72
public setSession(mixed $id)

Set session ID.

Only for testing

Parameters

mixed $id

at line 86
public LocationCreateStruct newLocationCreateStruct(mixed $parentLocationId)

Instantiates a new location create class.

Parameters

mixed $parentLocationId the parent under which the new location should be created

Return Value

LocationCreateStruct

at line 108
public Location createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct)

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

Parameters

ContentInfo $contentInfo
LocationCreateStruct $locationCreateStruct

Return Value

Location the newly created Location

Exceptions

UnauthorizedException If the current user user is not allowed to create this location
InvalidArgumentException if the content is already below the specified parent or the parent is a sub location of the location the content or if set the remoteId exists already

at line 133
public Location loadLocation(mixed $locationId)

Loads a location object from its $locationId.

Parameters

mixed $locationId

Return Value

Location

Exceptions

UnauthorizedException If the current user user is not allowed to read this location
NotFoundException If the specified location is not found

at line 156
public Location loadLocationByRemoteId(string $remoteId)

Loads a location object from its $remoteId.

Parameters

string $remoteId

Return Value

Location

Exceptions

UnauthorizedException If the current user user is not allowed to read this location
NotFoundException If the specified location is not found

at line 174
public LocationUpdateStruct newLocationUpdateStruct()

Instantiates a new location update class.

Return Value

LocationUpdateStruct

at line 190
public Location updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct)

Updates $location in the content repository.

Parameters

Location $location
LocationUpdateStruct $locationUpdateStruct

Return Value

Location the updated Location

Exceptions

UnauthorizedException If the current user user is not allowed to update this location
InvalidArgumentException if if set the remoteId exists already

at line 218
public Location[] loadLocations(ContentInfo $contentInfo, Location $rootLocation = null)

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

ContentInfo $contentInfo
Location $rootLocation

Return Value

Location[] An array of {@link Location}

Exceptions

BadStateException if there is no published version yet

at line 241
public LocationList loadLocationChildren(Location $location, int $offset, int $limit = 25)

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

Parameters

Location $location
int $offset the start offset for paging
int $limit the number of locations returned

Return Value

LocationList

at line 262
public int getLocationChildCount(Location $location)

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

Parameters

Location $location

Return Value

int

at line 275
public swapLocation(Location $location1, Location $location2)

Swaps the contents hold by the $location1 and $location2.

Parameters

Location $location1
Location $location2

Exceptions

UnauthorizedException If the current user user is not allowed to swap content

at line 289
public Location hideLocation(Location $location)

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

Parameters

Location $location

Return Value

Location $location, with updated hidden value

Exceptions

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

at line 306
public Location unhideLocation(Location $location)

Unhides the $location.

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

Parameters

Location $location

Return Value

Location $location, with updated hidden value

Exceptions

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

at line 318
public deleteLocation(Location $location)

Deletes $location and all its descendants.

Parameters

Location $location

Exceptions

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

at line 339
public Location copySubtree(Location $subtree, Location $targetParentLocation)

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

Location $subtree
  • the subtree denoted by the location to copy
Location $targetParentLocation
  • the target parent location for the copy operation

Return Value

Location The newly created location of the copied subtree

Exceptions

UnauthorizedException If the current user user is not allowed copy the subtree to the given parent location
InvalidArgumentException if the target location is a sub location of the given location

at line 355
public moveSubtree(Location $location, Location $newParentLocation)

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

Location $location
Location $newParentLocation

Exceptions

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