removeLocation() abstract public method

Deletes ezcontentobject_tree row for given $locationId (node_id).
abstract public removeLocation ( mixed $locationId )
$locationId mixed
示例#1
0
 /**
  * Sends a subtree starting to $locationId to the trash
  * and returns a Trashed object corresponding to $locationId.
  *
  * Moves all locations in the subtree to the Trash. The associated content
  * objects are left untouched.
  *
  * @param mixed $locationId
  *
  * @todo Handle field types actions
  *
  * @return null|\eZ\Publish\SPI\Persistence\Content\Location\Trashed null if location was deleted, otherwise Trashed object
  */
 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);
 }
 /**
  * Deletes ezcontentobject_tree row for given $locationId (node_id)
  *
  * @param mixed $locationId
  */
 public function removeLocation($locationId)
 {
     try {
         return $this->innerGateway->removeLocation($locationId);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
示例#3
0
 /**
  * Removes all Locations under and including $locationId.
  *
  * 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.
  *
  * @param mixed $locationId
  *
  * @return bool
  */
 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);
 }