Interface

eZ\Publish\API\Repository\TrashService

interface TrashService

Trash service, used for managing trashed content.

Methods

TrashItem loadTrashItem(mixed $trashItemId)

Loads a trashed location object from its $id.

null|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 32
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 46
public null|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

null|TrashItem null if location was deleted, otherwise TrashItem

Exceptions

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

at line 60
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 70
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 81
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 92
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