Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
eZ\Publish\Core\Repository\TrashService Class Reference

Trash service, used for managing trashed content. More...

Inheritance diagram for eZ\Publish\Core\Repository\TrashService:

## Public Member Functions
| __construct (RepositoryInterface $repository, Handler $handler, Helper\NameSchemaService $nameSchemaService, PermissionCriterionResolver $permissionCriterionResolver, array $settings=[])
| Setups service with reference to repository object that created it & corresponding handler. More...
| loadTrashItem ($trashItemId)
| Loads a trashed location object from its $id. More...
| trash (Location $location)
| Sends $location and all its children to trash and returns the corresponding trash item. More...
| recover (APITrashItem $trashItem, Location $newParentLocation=null)
| Recovers the $trashedLocation at its original place if possible. More...
| emptyTrash ()
| Empties trash. More...
| deleteTrashItem (APITrashItem $trashItem)
| Deletes a trash item. More...
| findTrashItems (Query $query)
| Returns a collection of Trashed locations contained in the trash, which are readable by the current user. More...
Public Member Functions inherited from eZ\Publish\API\Repository\TrashService
| recover (TrashItem $trashItem, Location $newParentLocation=null)
| Recovers the $trashedLocation at its original place if possible. More...
| deleteTrashItem (TrashItem $trashItem)
| Deletes a trash item. More...

## Protected Member Functions
| buildDomainTrashItems (array $spiTrashItems)
| buildDomainTrashItemObject (Trashed $spiTrashItem, Content $content)
| getDateTime ($timestamp)

## Protected Attributes
| $repository
| $persistenceHandler
| $settings
| $nameSchemaService

## Private Member Functions
| userHasPermissionsToRemove (ContentInfo $contentInfo, Location $location)

## Detailed Description

Trash service, used for managing trashed content.

Definition at line 36 of file Core/Repository/TrashService.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\Repository\TrashService::__construct | ( | RepositoryInterface | $repository,
|  | Handler | $handler,
|  | Helper\NameSchemaService | $nameSchemaService,
|  | PermissionCriterionResolver | $permissionCriterionResolver,
|  | array | $settings = `[]`
| ) |  |

Setups service with reference to repository object that created it & corresponding handler.

Parameters

  \eZ\Publish\API\Repository\Repository | $repository |
  \eZ\Publish\SPI\Persistence\Handler | $handler |
  \eZ\Publish\Core\Repository\Helper\NameSchemaService | $nameSchemaService |
  \eZ\Publish\API\Repository\PermissionCriterionResolver | $permissionCriterionResolver |
  array | $settings |

Definition at line 59 of file Core/Repository/TrashService.php.

References eZ\Publish\Core\Repository\TrashService\$nameSchemaService, eZ\Publish\Core\Repository\TrashService\$repository, and eZ\Publish\Core\Repository\TrashService\$settings.

## Member Function Documentation

## ◆ buildDomainTrashItemObject()

eZ\Publish\Core\Repository\TrashService::buildDomainTrashItemObject | ( | Trashed | $spiTrashItem,
|  | Content | $content
| ) |  |
| protected

Definition at line 343 of file Core/Repository/TrashService.php.

Referenced by eZ\Publish\Core\Repository\TrashService\buildDomainTrashItems(), eZ\Publish\Core\Repository\TrashService\loadTrashItem(), and eZ\Publish\Core\Repository\TrashService\trash().

## ◆ buildDomainTrashItems()

eZ\Publish\Core\Repository\TrashService::buildDomainTrashItems | ( | array | $spiTrashItems | ) |
| protected

Definition at line 325 of file Core/Repository/TrashService.php.

References eZ\Publish\Core\Repository\TrashService\buildDomainTrashItemObject().

Referenced by eZ\Publish\Core\Repository\TrashService\findTrashItems().

## ◆ deleteTrashItem()

eZ\Publish\Core\Repository\TrashService::deleteTrashItem | ( | APITrashItem | $trashItem | ) |

Deletes a trash item.

The corresponding content object will be removed

Exceptions

Definition at line 255 of file Core/Repository/TrashService.php.

## ◆ emptyTrash()

eZ\Publish\Core\Repository\TrashService::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

Implements eZ\Publish\API\Repository\TrashService.

Definition at line 225 of file Core/Repository/TrashService.php.

## ◆ findTrashItems()

eZ\Publish\Core\Repository\TrashService::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

  \eZ\Publish\API\Repository\Values\Content\Query | $query |

Returns
  \eZ\Publish\API\Repository\Values\Content\Trash\SearchResult

Implements eZ\Publish\API\Repository\TrashService.

Definition at line 286 of file Core/Repository/TrashService.php.

References eZ\Publish\Core\Repository\TrashService\buildDomainTrashItems().

## ◆ getDateTime()

eZ\Publish\Core\Repository\TrashService::getDateTime | ( |  | $timestamp | ) |
| protected

Parameters

  int | $timestamp |

Returns
  \DateTime

Definition at line 369 of file Core/Repository/TrashService.php.

## ◆ loadTrashItem()

eZ\Publish\Core\Repository\TrashService::loadTrashItem | ( |  | $trashItemId | ) |

Loads a trashed location object from its $id.

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

Exceptions

Implements eZ\Publish\API\Repository\TrashService.

Definition at line 88 of file Core/Repository/TrashService.php.

References eZ\Publish\Core\Repository\TrashService\buildDomainTrashItemObject().

## ◆ recover()

eZ\Publish\Core\Repository\TrashService::recover | ( | APITrashItem | $trashItem,
|  | Location | $newParentLocation = `null`
| ) |  |

Recovers the $trashedLocation at its original place if possible.

Exceptions

Definition at line 163 of file Core/Repository/TrashService.php.

## ◆ trash()

eZ\Publish\Core\Repository\TrashService::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.

Exceptions

Implements eZ\Publish\API\Repository\TrashService.

Definition at line 118 of file Core/Repository/TrashService.php.

References eZ\Publish\Core\Repository\TrashService\buildDomainTrashItemObject(), eZ\Publish\API\Repository\Values\Content\Location\getContentInfo(), and eZ\Publish\Core\Repository\TrashService\userHasPermissionsToRemove().

## ◆ userHasPermissionsToRemove()

eZ\Publish\Core\Repository\TrashService::userHasPermissionsToRemove | ( | ContentInfo | $contentInfo,
|  | Location | $location
| ) |  |
| private

Parameters

  \eZ\Publish\API\Repository\Values\Content\ContentInfo | $contentInfo |
  \eZ\Publish\API\Repository\Values\Content\Location | $location |

Returns
  bool

Exceptions

Definition at line 386 of file Core/Repository/TrashService.php.

Referenced by eZ\Publish\Core\Repository\TrashService\trash().

## Member Data Documentation

## ◆ $nameSchemaService

eZ\Publish\Core\Repository\TrashService::$nameSchemaService
| protected

Definition at line 48 of file Core/Repository/TrashService.php.

Referenced by eZ\Publish\Core\Repository\TrashService\__construct().

## ◆ $persistenceHandler

eZ\Publish\Core\Repository\TrashService::$persistenceHandler
| protected

Definition at line 42 of file Core/Repository/TrashService.php.

## ◆ $repository

eZ\Publish\Core\Repository\TrashService::$repository
| protected

Definition at line 39 of file Core/Repository/TrashService.php.

Referenced by eZ\Publish\Core\Repository\TrashService\__construct().

## ◆ $settings

eZ\Publish\Core\Repository\TrashService::$settings
| protected

Definition at line 45 of file Core/Repository/TrashService.php.

Referenced by eZ\Publish\Core\Repository\TrashService\__construct().

The documentation for this class was generated from the following file:

- Core/Repository/TrashService.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.