Detailed Description
Node adds the concept of relations to PersistentObject.
It is the basic component for building object trees (although a Node can have more than one parents). Relations are stored as values where the value name is the role name. The Node class implements the Composite Pattern. Use the methods addNode(), deleteNode() to build/modify trees.
Public Member Functions | |
__construct (ObjectId $oid=null, array $initialData=null) | |
__clone () | |
getValueNames ($excludeTransient=false) | |
getValue ($name) | |
setValue ($name, $value, $forceSet=false, $trackChange=true) | |
removeValue ($name) | |
getIndispensableObjects () | |
mergeValues (PersistentObject $object) | |
getRelationNames () | |
addNode (PersistentObject $other, $role=null, $forceSet=false, $trackChange=true, $updateOtherSide=true) | |
getAddedNodes () | |
deleteNode (PersistentObject $other, $role=null, $updateOtherSide=true) | |
getDeletedNodes () | |
setNodeOrder (array $orderedList, array $movedList=null, $role=null) | |
getNodeOrder () | |
loadChildren ($role=null, $buildDepth=BuildDepth::SINGLE) | |
getNumChildren ($memOnly=true) | |
getFirstChild ($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) | |
getChildren ($memOnly=true) | |
getChildrenEx (ObjectId $oid=null, $role=null, $type=null, $values=null, $properties=null, $useRegExp=true) | |
getPossibleChildren () | |
loadParents ($role=null, $buildDepth=BuildDepth::SINGLE) | |
getNumParents ($memOnly=true) | |
getParent () | |
getFirstParent ($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) | |
getParents ($memOnly=true) | |
getParentsEx (ObjectId $oid=null, $role=null, $type=null, $values=null, $properties=null, $useRegExp=true) | |
getPossibleParents () | |
getNodeRelation ($object) | |
getRelatives ($hierarchyType, $memOnly=true) | |
getNumRelatives ($hierarchyType, $memOnly=true) | |
acceptVisitor ($visitor) | |
addRelation ($name) | |
getDisplayValue () | |
__toString () | |
Public Member Functions inherited from DefaultPersistentObject | |
getType () | |
getMapper () | |
getOID () | |
setOID (ObjectId $oid) | |
getState () | |
setState ($state) | |
delete () | |
copyValues (PersistentObject $object, $copyPkValues=true) | |
clearValues () | |
reset () | |
afterCreate () | |
beforeInsert () | |
afterInsert () | |
afterLoad () | |
beforeUpdate () | |
afterUpdate () | |
beforeDelete () | |
afterDelete () | |
hasValue ($name) | |
validateValues () | |
validateValue ($name, $value) | |
getChangedValues () | |
getOriginalValue ($name) | |
getProperty ($name) | |
setProperty ($name, $value) | |
getPropertyNames () | |
getValueProperty ($name, $property) | |
setValueProperty ($name, $property, $value) | |
getValuePropertyNames ($name) | |
dump () | |
serialize () | |
unserialize ($serialized) | |
Static Public Member Functions | |
static | filter (array $nodeList, ObjectId $oid=null, $type=null, $values=null, $properties=null, $useRegExp=true) |
Public Attributes | |
const | RELATION_STATE_UNINITIALIZED = -1 |
const | RELATION_STATE_INITIALIZING = -2 |
const | RELATION_STATE_INITIALIZED = -3 |
const | RELATION_STATE_LOADED = -4 |
Public Attributes inherited from PersistentObject | |
const | STATE_CLEAN = 0 |
const | STATE_DIRTY = 1 |
const | STATE_NEW = 2 |
const | STATE_DELETED = 3 |
Protected Member Functions | |
loadRelations (array $roles, $buildDepth=BuildDepth::SINGLE) | |
getRelations ($hierarchyType='all') | |
Protected Member Functions inherited from DefaultPersistentObject | |
setOIDInternal (ObjectId $oid, $triggerListeners) | |
setValueInternal ($name, $value) | |
validateValueAgainstValidateType ($name, $value) | |
Static Protected Member Functions | |
static | mergeObjectLists ($list1, $list2) |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | ObjectId | $oid = null , |
array | $initialData = null |
||
) |
Constructor.
- Parameters
-
$oid ObjectId instance (optional) $initialData Associative array with initial data to override default data (optional)
Reimplemented from DefaultPersistentObject.
Member Function Documentation
◆ __clone()
__clone | ( | ) |
- See also
- PersistentObject::__clone()
Reimplemented from DefaultPersistentObject.
◆ getValueNames()
getValueNames | ( | $excludeTransient = false | ) |
Reimplemented from DefaultPersistentObject.
◆ getValue()
getValue | ( | $name | ) |
- See also
- PersistentObject::getValue()
Reimplemented from DefaultPersistentObject.
◆ setValue()
setValue | ( | $name, | |
$value, | |||
$forceSet = false , |
|||
$trackChange = true |
|||
) |
- See also
- PersistentObject::setValue()
Reimplemented from DefaultPersistentObject.
Reimplemented in AbstractUser.
◆ removeValue()
removeValue | ( | $name | ) |
- See also
- PersistentObject::removeValue()
Reimplemented from DefaultPersistentObject.
◆ getIndispensableObjects()
getIndispensableObjects | ( | ) |
Reimplemented from DefaultPersistentObject.
◆ filter()
|
static |
Get Nodes that match given conditions from a list.
- Parameters
-
$nodeList An array of nodes to filter or a single Node. $oid The object id that the Nodes should match (optional, default: null) $type The type that the Nodes should match (either fully qualified or simple, if not ambiguous) (optional, default: null) $values An associative array holding key value pairs that the Node values should match (values are interpreted as regular expression, optional, default: null) $properties An associative array holding key value pairs that the Node properties should match (values are interpreted as regular expression, optional, default: null) $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: true)
- Returns
- An Array holding references to the Nodes that matched.
◆ mergeValues()
mergeValues | ( | PersistentObject | $object | ) |
- See also
- PersistentObject::mergeValues
Reimplemented from DefaultPersistentObject.
◆ mergeObjectLists()
|
staticprotected |
Merge two object lists using the following rules:
- proxies in list1 are replaced by the appropriate objects from list2
- proxies/objects from list2 that don't exist in list1 are added to list1
- Parameters
-
$list1 Array of PersistentObject(Proxy) instances $list2 Array of PersistentObject(Proxy) instances
- Returns
- Associative array with keys 'result' and 'added' and arrays of all and only added objects respectively.
◆ getRelationNames()
getRelationNames | ( | ) |
◆ addNode()
addNode | ( | PersistentObject | $other, |
$role = null , |
|||
$forceSet = false , |
|||
$trackChange = true , |
|||
$updateOtherSide = true |
|||
) |
Add a Node to the given relation.
Delegates to setValue internally.
- Parameters
-
$other PersistentObject $role The role of the Node in the created relation. If null, the role will be the Node's simple type (without namespace) (default: null) $forceSet
- See also
- PersistentObject::setValue()
- Parameters
-
$trackChange
- See also
- PersistentObject::setValue()
- Parameters
-
$updateOtherSide Boolean whether to update also the other side of the relation (default: true)
- Returns
- Boolean whether the operation succeeds or not
◆ getAddedNodes()
getAddedNodes | ( | ) |
◆ deleteNode()
deleteNode | ( | PersistentObject | $other, |
$role = null , |
|||
$updateOtherSide = true |
|||
) |
◆ getDeletedNodes()
getDeletedNodes | ( | ) |
◆ setNodeOrder()
setNodeOrder | ( | array | $orderedList, |
array | $movedList = null , |
||
$role = null |
|||
) |
Define the order of related Node instances.
The mapper is responsible for persisting the order of the given Node instances in relation to this Node.
- Note
- Note instances, that are not explicitly sortable by a sortkey (
- See also
- PersistenceMapper::getDefaultOrder()) will be ignored. If a given Node instance is not related to this Node yet, an exception will be thrown. Any not persisted definition of a previous call will be overwritten
◆ getNodeOrder()
getNodeOrder | ( | ) |
Get the order of related Node instances, if it was defined using the Node::setNodeOrder() method.
- Returns
- Associative array of with keys 'ordered', 'moved', 'role' or null
◆ loadChildren()
loadChildren | ( | $role = null , |
|
$buildDepth = BuildDepth::SINGLE |
|||
) |
Load the children of a given role and add them.
If all children should be loaded, set the role parameter to null.
- Parameters
-
$role The role of children to load (maybe null, to load all children) (default: null) $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (default: BuildDepth::SINGLE)
◆ getNumChildren()
getNumChildren | ( | $memOnly = true | ) |
◆ getFirstChild()
getFirstChild | ( | $role = null , |
|
$type = null , |
|||
$values = null , |
|||
$properties = null , |
|||
$useRegExp = true |
|||
) |
Get the first child that matches given conditions.
- Parameters
-
$role The role that the child should match (optional, default: null). $type The type that the child should match (either fully qualified or simple, if not ambiguous) (optional, default: null). $values An associative array holding key value pairs that the child values should match (optional, default: null). $properties An associative array holding key value pairs that the child properties should match (optional, default: null). $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: true)
- Returns
- Node instance or null.
◆ getChildren()
getChildren | ( | $memOnly = true | ) |
◆ getChildrenEx()
getChildrenEx | ( | ObjectId | $oid = null , |
$role = null , |
|||
$type = null , |
|||
$values = null , |
|||
$properties = null , |
|||
$useRegExp = true |
|||
) |
Get the children that match given conditions.
- Note
- This method will only return objects that are already loaded, to get all objects in the given relation (including proxies), use the Node::getValue() method and filter the returned list afterwards.
- Parameters
-
$oid The object id that the children should match (optional, default: null). $role The role that the children should match (optional, default: null). $type The type that the children should match (either fully qualified or simple, if not ambiguous) (optional, default: null). $values An associative array holding key value pairs that the children values should match (optional, default: null). $properties An associative array holding key value pairs that the children properties should match (optional, default: null). $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: true)
- Returns
- Array containing children Nodes that matched (proxies not included).
◆ getPossibleChildren()
getPossibleChildren | ( | ) |
◆ loadParents()
loadParents | ( | $role = null , |
|
$buildDepth = BuildDepth::SINGLE |
|||
) |
Load the parents of a given role and add them.
If all parents should be loaded, set the role parameter to null.
- Parameters
-
$role The role of parents to load (maybe null, to load all parents) (default: null) $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (default: BuildDepth::SINGLE)
◆ getNumParents()
getNumParents | ( | $memOnly = true | ) |
◆ getParent()
getParent | ( | ) |
◆ getFirstParent()
getFirstParent | ( | $role = null , |
|
$type = null , |
|||
$values = null , |
|||
$properties = null , |
|||
$useRegExp = true |
|||
) |
Get the first parent that matches given conditions.
- Parameters
-
$role The role that the parent should match (optional, default: null). $type The type that the parent should match (either fully qualified or simple, if not ambiguous) (optional, default: null). $values An associative array holding key value pairs that the parent values should match (optional, default: null). $properties An associative array holding key value pairs that the parent properties should match (optional, default: null). $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: true)
- Returns
- Node instance or null.
◆ getParents()
getParents | ( | $memOnly = true | ) |
◆ getParentsEx()
getParentsEx | ( | ObjectId | $oid = null , |
$role = null , |
|||
$type = null , |
|||
$values = null , |
|||
$properties = null , |
|||
$useRegExp = true |
|||
) |
Get the parents that match given conditions.
- Note
- This method will only return objects that are already loaded, to get all objects in the given relation (including proxies), use the Node::getValue() method and filter the returned list afterwards.
- Parameters
-
$oid The object id that the parent should match (optional, default: null). $role The role that the parents should match (optional, default: null). $type The type that the parents should match (either fully qualified or simple, if not ambiguous) (optional, default: null). $values An associative array holding key value pairs that the parent values should match (optional, default: null). $properties An associative array holding key value pairs that the parent properties should match (optional, default: null). $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: true)
- Returns
- Array containing parent Nodes that matched (proxies not included).
◆ getPossibleParents()
getPossibleParents | ( | ) |
◆ getNodeRelation()
getNodeRelation | ( | $object | ) |
◆ loadRelations()
|
protected |
Load all objects in the given set of relations.
- Parameters
-
$roles An array of relation (=role) names $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build (default: BuildDepth::SINGLE)
◆ getRelations()
|
protected |
◆ getRelatives()
getRelatives | ( | $hierarchyType, | |
$memOnly = true |
|||
) |
Get the relatives of a given hierarchyType.
- Parameters
-
$hierarchyType
- See also
- PersistenceMapper::getRelations
- Parameters
-
$memOnly Boolean whether to only get the relatives in memory or all relatives (including proxies) (default: true).
- Returns
- An array containing the relatives.
◆ getNumRelatives()
getNumRelatives | ( | $hierarchyType, | |
$memOnly = true |
|||
) |
Get the number of relatives of a given hierarchyType.
- Parameters
-
$hierarchyType
- See also
- PersistenceMapper::getRelations
- Parameters
-
$memOnly Boolean whether to only get the number of the relatives in memory or all relatives (default: true).
- Returns
- The number of relatives.
◆ acceptVisitor()
acceptVisitor | ( | $visitor | ) |
◆ addRelation()
addRelation | ( | $name | ) |
◆ getDisplayValue()
getDisplayValue | ( | ) |
Output.
- See also
- PersistentObject::getDisplayValue() Delegates to NodeUtil::getDisplayValue
Reimplemented from DefaultPersistentObject.
◆ __toString()
__toString | ( | ) |
Get a string representation of the Node.
- Returns
- The string representation of the Node.
Reimplemented from DefaultPersistentObject.