public function trashSubtree($locationId)
{
$locationRows = $this->locationGateway->getSubtreeContent($locationId);
$isLocationRemoved = false;
$parentLocationId = null;
foreach ($locationRows as $locationRow) {
if ($locationRow['node_id'] == $locationId) {
$parentLocationId = $locationRow['parent_node_id'];
}
if ($this->locationGateway->countLocationsByContentId($locationRow['contentobject_id']) == 1) {
$this->locationGateway->trashLocation($locationRow['node_id']);
} else {
if ($locationRow['node_id'] == $locationId) {
$isLocationRemoved = true;
}
$this->locationGateway->removeLocation($locationRow['node_id']);
if ($locationRow['node_id'] == $locationRow['main_node_id']) {
$newMainLocationRow = $this->locationGateway->getFallbackMainNodeData($locationRow['contentobject_id'], $locationRow['node_id']);
$this->locationHandler->changeMainLocation($locationRow['contentobject_id'], $newMainLocationRow['node_id'], $newMainLocationRow['contentobject_version'], $newMainLocationRow['parent_node_id']);
}
}
}
if (isset($parentLocationId)) {
$this->locationHandler->markSubtreeModified($parentLocationId, time());
}
return $isLocationRemoved ? null : $this->loadTrashItem($locationId);
}