eZPublishCommunityProject  2012.12
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase Class Reference

Location gateway implementation using the zeta database component. More...

+ Inheritance diagram for eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase:
+ Collaboration diagram for eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase:

Public Member Functions

 __construct (EzcDbHandler $handler)
 Construct from database handler. More...
 
 changeMainLocation ($contentId, $locationId, $versionNo, $parentLocationId)
 Changes main location of content identified by given $contentId to location identified by given $locationId. More...
 
 cleanupTrash ()
 Removes every entries in the trash. More...
 
 countLocationsByContentId ($contentId)
 Returns how many locations given content object identified by $contentId has. More...
 
 createLocationsFromNodeAssignments ($contentId, $versionNo)
 Create locations from node assignments. More...
 
 createNodeAssignment (CreateStruct $createStruct, $parentNodeId, $type=self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)
 Create an entry in the node assignment table. More...
 
 deleteNodeAssignment ($contentId, $versionNo=null)
 Deletes node assignment for given $contentId and $versionNo. More...
 
 getBasicNodeData ($nodeId)
 Returns an array with basic node data. More...
 
 getBasicNodeDataByRemoteId ($remoteId)
 Returns an array with basic node data. More...
 
 getChildren ($locationId)
 Returns data for the first level children of the location identified by given $locationId. More...
 
 getFallbackMainNodeData ($contentId, $locationId)
 Returns id of the next in line node to be set as a new main node. More...
 
 getSubtreeContent ($sourceId)
 Find all content in the given subtree. More...
 
 hideSubtree ($pathString)
 Sets a location to be hidden, and it self + all children to invisible. More...
 
 listTrashed ($offset, $limit, array $sort=null)
 List trashed items. More...
 
 loadLocationDataByContent ($contentId, $rootLocationId=null)
 Loads data for all Locations for $contentId, optionally only in the subtree starting at $rootLocationId. More...
 
 loadTrashByLocation ($locationId)
 Loads trash data specified by location ID. More...
 
 removeElementFromTrash ($id)
 Removes trashed element identified by $id from trash. More...
 
 removeLocation ($locationId)
 Deletes ezcontentobject_tree row for given $locationId (node_id) More...
 
 setSectionForSubtree ($pathString, $sectionId)
 Set section on all content objects in the subtree. More...
 
 swap ($locationId1, $locationId2)
 Swaps the content object being pointed to by a location object. More...
 
 unHideSubtree ($pathString)
 Sets a location to be unhidden, and self + children to visible unless a parent is hiding the tree. More...
 
 untrashLocation ($locationId, $newParentId=null)
 Returns a trashed location to normal state. More...
 
 update (UpdateStruct $location, $locationId)
 Updates an existing location. More...
 
 updateLocationsContentVersionNo ($contentId, $versionNo)
 Updates all Locations of content identified with $contentId with $versionNo. More...
 
 updateNodeAssignment ($contentObjectId, $oldParent, $newParent, $opcode)
 Update node assignment table. More...
 
 updateSubtreeModificationTime ($pathString, $timestamp=null)
 Updated subtree modification time for all nodes on path. More...
 
- Public Member Functions inherited from eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
 changeMainLocation ($contentId, $locationId, $versionNo, $parentLocationId)
 Changes main location of content identified by given $contentId to location identified by given $locationId. More...
 
 cleanupTrash ()
 Removes every entries in the trash. More...
 
 countLocationsByContentId ($contentId)
 Returns how many locations given content object identified by $contentId has. More...
 
 create (CreateStruct $createStruct, array $parentNode)
 Creates a new location in given $parentNode. More...
 
 createLocationsFromNodeAssignments ($contentId, $versionNo)
 Create locations from node assignments. More...
 
 createNodeAssignment (CreateStruct $createStruct, $parentNodeId, $type=self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)
 Create an entry in the node assignment table. More...
 
 deleteNodeAssignment ($contentId, $versionNo=null)
 Deletes node assignment for given $contentId and $versionNo. More...
 
 getBasicNodeData ($nodeId)
 Returns an array with basic node data. More...
 
 getBasicNodeDataByRemoteId ($remoteId)
 Returns an array with basic node data for the node with $remoteId. More...
 
 getChildren ($locationId)
 Returns data for the first level children of the location identified by given $locationId. More...
 
 getFallbackMainNodeData ($contentId, $locationId)
 Returns id of the next in line node to be set as a new main node. More...
 
 getSubtreeContent ($sourceId)
 Find all content in the given subtree. More...
 
 hideSubtree ($pathString)
 Sets a location to be hidden, and it self + all children to invisible. More...
 
 listTrashed ($offset, $limit, array $sort=null)
 Lists trashed items. More...
 
 loadLocationDataByContent ($contentId, $rootLocationId=null)
 Loads data for all Locations for $contentId, optionally only in the subtree starting at $rootLocationId. More...
 
 loadTrashByLocation ($locationId)
 Loads trash data specified by location ID. More...
 
 moveSubtreeNodes ($fromPathString, $toPathString)
 Update path strings to move nodes in the ezcontentobject_tree table. More...
 
 removeElementFromTrash ($id)
 Removes trashed element identified by $id from trash. More...
 
 removeLocation ($locationId)
 Deletes ezcontentobject_tree row for given $locationId (node_id) More...
 
 setSectionForSubtree ($pathString, $sectionId)
 Set section on all content objects in the subtree. More...
 
 swap ($locationId1, $locationId2)
 Swaps the content object being pointed to by a location object. More...
 
 trashLocation ($locationId)
 Sends a single location identified by given $locationId to the trash. More...
 
 unHideSubtree ($pathString)
 Sets a location to be unhidden, and self + children to visible unless a parent is hiding the tree. More...
 
 untrashLocation ($locationId, $newParentId=null)
 Returns a trashed location to normal state. More...
 
 update (UpdateStruct $location, $locationId)
 Updates an existing location. More...
 
 updateLocationsContentVersionNo ($contentId, $versionNo)
 Updates all Locations of content identified with $contentId with $versionNo. More...
 
 updateNodeAssignment ($contentObjectId, $oldParent, $newParent, $opcode)
 Update node assignment table. More...
 
 updatePathIdentificationString ($locationId, $parentLocationId, $text)
 Updates path identification string for given $locationId. More...
 
 updateSubtreeModificationTime ($pathString, $timestamp=null)
 Updated subtree modification time for all nodes on path. More...
 

Protected Member Functions

 applySubtreeLimitation (\ezcQuery $query, $rootLocationId)
 Limits the given $query to the subtree starting at $rootLocationId. More...
 

Protected Attributes

 $handler
 

Private Member Functions

 getMainNodeId ($contentId)
 Searches for the main nodeId of $contentId in $versionId. More...
 

Additional Inherited Members

- Public Attributes inherited from eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
const NODE_ASSIGNMENT_OP_CODE_CREATE = 3
 
const NODE_ASSIGNMENT_OP_CODE_CREATE_NOP = 2
 
const NODE_ASSIGNMENT_OP_CODE_EXECUTE = 1
 
const NODE_ASSIGNMENT_OP_CODE_MOVE = 5
 
const NODE_ASSIGNMENT_OP_CODE_MOVE_NOP = 4
 
const NODE_ASSIGNMENT_OP_CODE_NOP = 0
 Constants for node assignment op codes. More...
 
const NODE_ASSIGNMENT_OP_CODE_REMOVE = 7
 
const NODE_ASSIGNMENT_OP_CODE_REMOVE_NOP = 6
 
const NODE_ASSIGNMENT_OP_CODE_SET = 9
 
const NODE_ASSIGNMENT_OP_CODE_SET_NOP = 8
 

Detailed Description

Location gateway implementation using the zeta database component.

Constructor & Destructor Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::__construct ( EzcDbHandler  $handler)

Construct from database handler.

Parameters
\eZ\Publish\Core\Persistence\Legacy\EzcDbHandler$handler
Returns
void

Member Function Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::applySubtreeLimitation ( \ezcQuery  $query,
  $rootLocationId 
)
protected

Limits the given $query to the subtree starting at $rootLocationId.

Parameters
\ezcQuery$query
string$rootLocationId
Returns
void

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\getSubtreeContent(), and eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\loadLocationDataByContent().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::changeMainLocation (   $contentId,
  $locationId,
  $versionNo,
  $parentLocationId 
)

Changes main location of content identified by given $contentId to location identified by given $locationId.

Updates ezcontentobject_tree table for the given $contentId and eznode_assignment table for the given $contentId, $parentLocationId and $versionNo

Parameters
mixed$contentId
mixed$locationId
mixed$versionNoversion number, needed to update eznode_assignment table
mixed$parentLocationIdparent location of location identified by $locationId, needed to update eznode_assignment table
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::cleanupTrash ( )

Removes every entries in the trash.

Will NOT remove associated content objects nor attributes.

Basically truncates ezcontentobject_trash table.

Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::countLocationsByContentId (   $contentId)

Returns how many locations given content object identified by $contentId has.

Parameters
int$contentId
Returns
int
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::createLocationsFromNodeAssignments (   $contentId,
  $versionNo 
)

Create locations from node assignments.

Convert existing node assignments into real locations.

Parameters
mixed$contentId
mixed$versionNo
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::createNodeAssignment ( CreateStruct  $createStruct,
  $parentNodeId,
  $type = self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP 
)

Create an entry in the node assignment table.

Parameters
\eZ\Publish\SPI\Persistence\Content\Location\CreateStruct$createStruct
mixed$parentNodeId
int$type
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::deleteNodeAssignment (   $contentId,
  $versionNo = null 
)

Deletes node assignment for given $contentId and $versionNo.

If $versionNo is not passed all node assignments for given $contentId are deleted

Parameters
int$contentId
int | null$versionNo
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getBasicNodeData (   $nodeId)

Returns an array with basic node data.

We might want to cache this, since this method is used by about every method in the location handler.

Todo:
optimize
Parameters
mixed$nodeId
Returns
array

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\createLocationsFromNodeAssignments(), and eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\untrashLocation().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getBasicNodeDataByRemoteId (   $remoteId)

Returns an array with basic node data.

Todo:
optimize
Parameters
mixed$remoteId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getChildren (   $locationId)

Returns data for the first level children of the location identified by given $locationId.

Parameters
mixed$locationId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getFallbackMainNodeData (   $contentId,
  $locationId 
)

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.

Parameters
mixed$contentId
mixed$locationId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getMainNodeId (   $contentId)
private

Searches for the main nodeId of $contentId in $versionId.

Parameters
int$contentId
Returns
int|bool

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\createLocationsFromNodeAssignments().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::getSubtreeContent (   $sourceId)

Find all content in the given subtree.

Parameters
mixed$sourceId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::hideSubtree (   $pathString)

Sets a location to be hidden, and it self + all children to invisible.

Parameters
string$pathString
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::listTrashed (   $offset,
  $limit,
array  $sort = null 
)

List trashed items.

Parameters
int$offset
int$limit
array$sort
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::loadLocationDataByContent (   $contentId,
  $rootLocationId = null 
)

Loads data for all Locations for $contentId, optionally only in the subtree starting at $rootLocationId.

Parameters
int$contentId
int$rootLocationId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::loadTrashByLocation (   $locationId)

Loads trash data specified by location ID.

Parameters
mixed$locationId
Returns
array

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\untrashLocation().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::removeElementFromTrash (   $id)

Removes trashed element identified by $id from trash.

Will NOT remove associated content object nor attributes.

Parameters
int$idThe trashed location Id
Returns
void

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\untrashLocation().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::removeLocation (   $locationId)

Deletes ezcontentobject_tree row for given $locationId (node_id)

Parameters
mixed$locationId
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::setSectionForSubtree (   $pathString,
  $sectionId 
)

Set section on all content objects in the subtree.

Parameters
mixed$pathString
mixed$sectionId
Returns
boolean
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::swap (   $locationId1,
  $locationId2 
)

Swaps the content object being pointed to by a location object.

Make the location identified by $locationId1 refer to the Content referred to by $locationId2 and vice versa.

Parameters
mixed$locationId1
mixed$locationId2
Returns
boolean
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::unHideSubtree (   $pathString)

Sets a location to be unhidden, and self + children to visible unless a parent is hiding the tree.

If not make sure only children down to first hidden node is marked visible.

Parameters
string$pathString
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::untrashLocation (   $locationId,
  $newParentId = null 
)

Returns a trashed location to normal state.

Recreates the originally trashed location in the new position. If no new position has been specified, it will be tried to re-create the location at the old position. If this is not possible ( because the old location does not exist any more) and exception is thrown.

Parameters
mixed$locationId
mixed | null$newParentId
Returns
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::update ( UpdateStruct  $location,
  $locationId 
)

Updates an existing location.

Parameters
\eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct$location
int$locationId
Returns
boolean
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::updateLocationsContentVersionNo (   $contentId,
  $versionNo 
)

Updates all Locations of content identified with $contentId with $versionNo.

Parameters
mixed$contentId
mixed$versionNo
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::updateNodeAssignment (   $contentObjectId,
  $oldParent,
  $newParent,
  $opcode 
)

Update node assignment table.

Parameters
int$contentObjectId
int$oldParent
int$newParent
int$opcode
Returns
void

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase\createLocationsFromNodeAssignments().

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::updateSubtreeModificationTime (   $pathString,
  $timestamp = null 
)

Updated subtree modification time for all nodes on path.

Parameters
string$pathString
int | null$timestamp
Returns
void

Member Data Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\EzcDatabase::$handler
protected

The documentation for this class was generated from the following file: