countLocationsByContentId() abstract public method

Returns how many locations given content object identified by $contentId has.
abstract public countLocationsByContentId ( integer $contentId ) : integer
$contentId integer
return integer
示例#1
0
 /**
  * Triggers delete operations for $trashItem.
  * If there is no more locations for corresponding content, then it will be deleted as well.
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Location\Trashed $trashItem
  *
  * @return void
  */
 protected function delete(Trashed $trashItem)
 {
     $this->locationGateway->removeElementFromTrash($trashItem->id);
     if ($this->locationGateway->countLocationsByContentId($trashItem->contentId) < 1) {
         $this->contentHandler->deleteContent($trashItem->contentId);
     }
 }
 /**
  * Returns how many locations given content object identified by $contentId has
  *
  * @param int $contentId
  *
  * @return int
  */
 public function countLocationsByContentId($contentId)
 {
     try {
         return $this->innerGateway->countLocationsByContentId($contentId);
     } 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);
 }