Class

eZ\Publish\Core\REST\Client\TrashService

class TrashService implements TrashService, Sessionable

Trash service used for content/location trash handling.

Methods

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

setSession(mixed $id)

Set session ID.

TrashItem loadTrashItem(mixed $trashItemId)

Loads a trashed location object from its $id.

TrashItem trash(Location $location)

Sends $location and all its children to trash and returns the corresponding trash item.

Location recover(TrashItem $trashItem, Location $newParentLocation = null)

Recovers the $trashedLocation at its original place if possible.

emptyTrash()

Empties trash.

deleteTrashItem(TrashItem $trashItem)

Deletes a trash item.

SearchResult findTrashItems(Query $query)

Returns a collection of Trashed locations contained in the trash, which are readable by the current user.

Details

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

Parameters

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

at line 76
public setSession(mixed $id)

Set session ID.

Only for testing

Parameters

mixed $id

at line 95
public TrashItem loadTrashItem(mixed $trashItemId)

Loads a trashed location object from its $id.

Note that $id is identical to original location, which has been previously trashed

Parameters

mixed $trashItemId

Return Value

TrashItem

Exceptions

UnauthorizedException if the user is not allowed to read the trashed location
NotFoundException
  • if the location with the given id does not exist

at line 122
public TrashItem trash(Location $location)

Sends $location and all its children to trash and returns the corresponding trash item.

The current user may not have access to the returned trash item, check before using it. Content is left untouched.

Parameters

Location $location

Return Value

TrashItem null if location was deleted, otherwise TrashItem

Exceptions

UnauthorizedException if the user is not allowed to trash the given location

at line 139
public Location recover(TrashItem $trashItem, Location $newParentLocation = null)

Recovers the $trashedLocation at its original place if possible.

Parameters

TrashItem $trashItem
Location $newParentLocation

Return Value

Location the newly created or recovered location

Exceptions

UnauthorizedException if the user is not allowed to recover the trash item at the parent location location If $newParentLocation is provided, $trashedLocation will be restored under it.

at line 152
public emptyTrash()

Empties trash.

All locations contained in the trash will be removed. Content objects will be removed if all locations of the content are gone.

Exceptions

UnauthorizedException if the user is not allowed to empty the trash

at line 180
public deleteTrashItem(TrashItem $trashItem)

Deletes a trash item.

The corresponding content object will be removed

Parameters

TrashItem $trashItem

Exceptions

UnauthorizedException if the user is not allowed to delete this trash item

at line 208
public SearchResult findTrashItems(Query $query)

Returns a collection of Trashed locations contained in the trash, which are readable by the current user.

$query allows to filter/sort the elements to be contained in the collection.

Parameters

Query $query

Return Value

SearchResult