The associated content object is left untouched.
abstract public trashLocation ( mixed $locationId ) : boolean | ||
$locationId | mixed | |
Результат | boolean |
/** * 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); }
/** * Sends a single location identified by given $locationId to the trash. * * The associated content object is left untouched. * * @param mixed $locationId * * @return boolean */ public function trashLocation($locationId) { try { return $this->innerGateway->trashLocation($locationId); } catch (DBALException $e) { throw new RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new RuntimeException('Database error', 0, $e); } }