eZ\Publish\Core\Persistence\Legacy\Content\TreeHandler::removeSubtree PHP Метод

removeSubtree() публичный Метод

Performs a recursive delete on the location identified by $locationId, including all of its child locations. Content which is not referred to by any other location is automatically removed. Content which looses its main Location will get the first of its other Locations assigned as the new main Location.
public removeSubtree ( mixed $locationId ) : boolean
$locationId mixed
Результат boolean
    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);
    }

Usage Example

Пример #1
0
 /**
  * Deletes all versions and fields, all locations (subtree), and all relations.
  *
  * Removes the relations, but not the related objects. All subtrees of the
  * assigned nodes of this content objects are removed (recursively).
  *
  * @param int $contentId
  *
  * @return bool
  */
 public function deleteContent($contentId)
 {
     $contentLocations = $this->contentGateway->getAllLocationIds($contentId);
     if (empty($contentLocations)) {
         $this->removeRawContent($contentId);
     } else {
         foreach ($contentLocations as $locationId) {
             $this->treeHandler->removeSubtree($locationId);
         }
     }
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Legacy\Content\TreeHandler::removeSubtree