eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway::trashLocation PHP Method

trashLocation() abstract public method

The associated content object is left untouched.
abstract public trashLocation ( mixed $locationId ) : boolean
$locationId mixed
return boolean
    public abstract function trashLocation($locationId);

Usage Example

Ejemplo n.º 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);
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway::trashLocation