public function removeSubtree($locationId)
{
$locationRow = $this->locationGateway->getBasicNodeData($locationId);
$contentId = $locationRow['contentobject_id'];
$mainLocationId = $locationRow['main_node_id'];
$subLocations = $this->locationGateway->getChildren($locationId);
foreach ($subLocations as $subLocation) {
$this->removeSubtree($subLocation['node_id']);
}
if ($locationId == $mainLocationId) {
if (1 == $this->locationGateway->countLocationsByContentId($contentId)) {
$this->removeRawContent($contentId);
} else {
$newMainLocationRow = $this->locationGateway->getFallbackMainNodeData($contentId, $locationId);
$this->changeMainLocation($contentId, $newMainLocationRow['node_id'], $newMainLocationRow['contentobject_version'], $newMainLocationRow['parent_node_id']);
}
}
$this->locationGateway->removeLocation($locationId);
$this->locationGateway->deleteNodeAssignment($contentId);
}