getFallbackMainNodeData() абстрактный публичный Метод

This returns lowest node id for content identified by $contentId, and not of the node identified by given $locationId (current main node). Assumes that content has more than one location.
abstract public getFallbackMainNodeData ( mixed $contentId, mixed $locationId ) : array
$contentId mixed
$locationId mixed
Результат array
Пример #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);
 }
Пример #2
0
 /**
  * Returns id of the next in line node to be set as a new main node
  *
  * This returns lowest node id for content identified by $contentId, and not of
  * the node identified by given $locationId (current main node).
  * Assumes that content has more than one location.
  *
  * @param mixed $contentId
  * @param mixed $locationId
  *
  * @return array
  */
 public function getFallbackMainNodeData($contentId, $locationId)
 {
     try {
         return $this->innerGateway->getFallbackMainNodeData($contentId, $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);
 }