public function trash(Location $location)
{
if (!is_numeric($location->id)) {
throw new InvalidArgumentValue('id', $location->id, 'Location');
}
if ($this->repository->canUser('content', 'manage_locations', $location->getContentInfo(), $location) !== true) {
throw new UnauthorizedException('content', 'manage_locations');
}
$this->repository->beginTransaction();
try {
$spiTrashItem = $this->persistenceHandler->trashHandler()->trashSubtree($location->id);
$this->persistenceHandler->urlAliasHandler()->locationDeleted($location->id);
$this->repository->commit();
} catch (Exception $e) {
$this->repository->rollback();
throw $e;
}
return isset($spiTrashItem) ? $this->buildDomainTrashItemObject($spiTrashItem) : null;
}