PHP Class Jackalope\Node

You can iterate over the nodes children because it is an IteratorAggregate
Inheritance: extends Item, implements IteratorAggregat\IteratorAggregate, implements PHPCR\NodeInterface
ファイルを表示 Open project: jackalope/jackalope Class Usage Examples

Protected Properties

Property Type Description
$definition PHPCR\NodeType\NodeDefinitionInterface Cached instance of the node definition that defines this node
$deletedProperties this is needed in order to track deletions in case of refresh keys are the property names, values the properties (in state deleted)
$index integer TODO: fully implement same-name siblings
$nodes array ordered list of the child node names
$originalNodesOrder array used to calculate reordering operations if orderBefore() was used
$primaryType string The primary type name of this node
$properties Property[] all properties are instantiated in the constructor OPTIMIZE: lazy instantiate property objects, just have local array of values

Public Methods

Method Description
__construct ( jackalope\FactoryInterface $factory, array $rawData, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false ) Create a new node instance with data from the storage layer
addChildNode ( PHPCR\NodeInterface $node, boolean $check, string $name = null ) Adds child node to this node for internal reference
addMixin ( $mixinName ) {@inheritDoc}
addNode ( $relPath, $primaryNodeTypeName = null ) Creates a new node at the specified $relPath
addNodeAutoNamed ( $nameHint = null, $primaryNodeTypeName = null ) {@inheritDoc}
beginTransaction ( ) {@inheritDoc}
canAddMixin ( $mixinName ) {@inheritDoc}
commitTransaction ( ) {@inheritDoc}
confirmSaved ( ) In addition to calling parent method, tell all properties and clean deletedProperties
followLifecycleTransition ( $transition ) {@inheritDoc}
getAllowedLifecycleTransitions ( ) {@inheritDoc}
getCorrespondingNodePath ( $workspaceName ) {@inheritDoc}
getDefinition ( ) {@inheritDoc}
getIdentifier ( ) {@inheritDoc}
getIndex ( ) {@inheritDoc}
getIterator ( ) : Iterator Provide Traversable interface: redirect to getNodes with no filter
getMixinNodeTypes ( ) {@inheritDoc}
getNode ( $relPath ) {@inheritDoc}
getNodeNames ( $nameFilter = null, $typeFilter = null ) {@inheritDoc}
getNodes ( $nameFilter = null, $typeFilter = null ) {@inheritDoc}
getOrderCommands ( ) : array Returns the orderBefore commands to be applied to the childnodes to get from the original order to the new one
getPrimaryItem ( ) {@inheritDoc}
getPrimaryNodeType ( ) {@inheritDoc}
getProperties ( $nameFilter = null ) {@inheritDoc}
getPropertiesForStoreDeletedNode ( ) : Property[] This method is only meant for the transport to be able to still build a store request for afterwards deleted nodes to support the operationslog.
getPropertiesValues ( $nameFilter = null, $dereference = true ) {@inheritDoc}
getProperty ( $relPath ) {@inheritDoc}
getPropertyValue ( $name, $type = null ) {@inheritDoc}
getPropertyValueWithDefault ( $relPath, $defaultValue ) {@inheritDoc}
getReferences ( $name = null ) {@inheritDoc}
getSharedSet ( ) {@inheritDoc}
getWeakReferences ( $name = null ) {@inheritDoc}
hasNode ( $relPath ) {@inheritDoc}
hasNodes ( ) {@inheritDoc}
hasProperties ( ) {@inheritDoc}
hasProperty ( $relPath ) {@inheritDoc}
isCheckedOut ( ) {@inheritDoc}
isLocked ( ) {@inheritDoc}
isNodeType ( $nodeTypeName ) {@inheritDoc}
needsChildReordering ( ) : boolean Determine whether the children of this node need to be reordered
orderBefore ( $srcChildRelPath, $destChildRelPath ) Jackalope implements this feature and updates the position of the existing child at srcChildRelPath to be in the list immediately before destChildRelPath.
remove ( ) Remove this node
removeMixin ( $mixinName ) {@inheritDoc}
removeShare ( ) {@inheritDoc}
removeSharedSet ( ) {@inheritDoc}
rename ( $newName ) {@inheritDoc}
rollbackTransaction ( ) {@inheritDoc}
setChildrenDirty ( ) Mark all cached children as dirty.
setDeleted ( ) In addition to set this item deleted, set all properties to deleted.
setDirty ( $keepChanges = false, $targetState = false ) Overwrite to set the properties dirty as well.
setMixins ( array $mixinNames ) {@inheritDoc}
setPath ( $path, $move = false ) In addition to calling parent method, tell all properties
setPrimaryType ( $nodeTypeName ) Changes the primary node type of this node to nodeTypeName.
setProperty ( $name, $value, $type = PropertyType::UNDEFINED, boolean $validate = true ) {@inheritDoc}
unsetChildNode ( string $name, boolean $check ) Removes the reference in the internal node storage
unsetProperty ( string $name ) Removes the reference in the internal node storage
update ( $srcWorkspace ) {@inheritDoc}

Protected Methods

Method Description
_setProperty ( string $name, mixed $value, string $type, boolean $internal ) : Property Implement really setting the property without any notification.
filterNames ( string | array $filter, array $names ) : array Filter the list of names according to the filter expression / array
generateUuid ( ) : string
getChildPath ( string $p ) : string Make sure $p is an absolute path
refresh ( $keepChanges, $internal = false ) Refresh this node

Private Methods

Method Description
parseData ( array $rawData, boolean $update, boolean $keepChanges = false ) Initialize or update this object with raw data from backend.

Method Details

__construct() public method

This is only to be called by the Factory::get() method even inside the Jackalope implementation to allow for custom implementations of Nodes.
See also: TransportInterface::getNode()
public __construct ( jackalope\FactoryInterface $factory, array $rawData, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false )
$factory jackalope\FactoryInterface the object factory
$rawData array in the format as returned from TransportInterface::getNode
$path string the absolute path of this node
$session jackalope\Session
$objectManager ObjectManager
$new boolean set to true if this is a new node being created. Defaults to false which means the node is loaded from storage.

_setProperty() protected method

Implement the setProperty, but also used from constructor or in refresh, when the backend has a new property that is not yet loaded in memory.
See also: Node::setProperty
See also: Node::refresh
See also: Node::__construct
protected _setProperty ( string $name, mixed $value, string $type, boolean $internal ) : Property
$name string
$value mixed
$type string
$internal boolean whether we are setting this node through api or internally
return Property

addChildNode() public method

Adds child node to this node for internal reference
public addChildNode ( PHPCR\NodeInterface $node, boolean $check, string $name = null )
$node PHPCR\NodeInterface The name of the child node
$check boolean whether to check state
$name string is used in cases where $node->getName would not return the correct name (during move operation)

addMixin() public method

Jackalope validates type conflicts only on save, not immediately. It is possible to add mixin types after the first save.
public addMixin ( $mixinName )

addNode() public method

{@inheritDoc} In Jackalope, the child node type definition is immediately applied if no primaryNodeTypeName is specified. The PathNotFoundException and ConstraintViolationException are thrown immediately. Version and Lock related exceptions are delayed until save.
public addNode ( $relPath, $primaryNodeTypeName = null )

addNodeAutoNamed() public method

{@inheritDoc}
public addNodeAutoNamed ( $nameHint = null, $primaryNodeTypeName = null )

beginTransaction() public method

Additionally, notifies all properties of this node. Child nodes are not notified, it is the job of the ObjectManager to know which nodes are cached and notify them.
public beginTransaction ( )

canAddMixin() public method

{@inheritDoc}
public canAddMixin ( $mixinName )

commitTransaction() public method

Additionally, notifies all properties of this node. Child nodes are not notified, it is the job of the ObjectManager to know which nodes are cached and notify them.
public commitTransaction ( )

confirmSaved() public method

In addition to calling parent method, tell all properties and clean deletedProperties
public confirmSaved ( )

filterNames() protected static method

Filter the list of names according to the filter expression / array
protected static filterNames ( string | array $filter, array $names ) : array
$filter string | array according to getNodes|getProperties
$names array list of names to filter
return array the names in $names that match the filter

followLifecycleTransition() public method

{@inheritDoc}
public followLifecycleTransition ( $transition )

generateUuid() protected method

protected generateUuid ( ) : string
return string a universally unique id.

getAllowedLifecycleTransitions() public method

{@inheritDoc}

getChildPath() protected method

If its a relative path, prepend the path to this node, otherwise return as is
protected getChildPath ( string $p ) : string
$p string the relative or absolute property or node path
return string the absolute path to this item, with relative paths resolved against the current node

getCorrespondingNodePath() public method

{@inheritDoc}
public getCorrespondingNodePath ( $workspaceName )

getDefinition() public method

{@inheritDoc}
public getDefinition ( )

getIdentifier() public method

{@inheritDoc}
public getIdentifier ( )

getIndex() public method

{@inheritDoc}
public getIndex ( )

getIterator() public method

Provide Traversable interface: redirect to getNodes with no filter
public getIterator ( ) : Iterator
return Iterator over all child nodes

getMixinNodeTypes() public method

{@inheritDoc}
public getMixinNodeTypes ( )

getNode() public method

{@inheritDoc}
public getNode ( $relPath )

getNodeNames() public method

{@inheritDoc}
public getNodeNames ( $nameFilter = null, $typeFilter = null )

getNodes() public method

{@inheritDoc}
public getNodes ( $nameFilter = null, $typeFilter = null )

getOrderCommands() public method

Returns the orderBefore commands to be applied to the childnodes to get from the original order to the new one
public getOrderCommands ( ) : array
return array of arrays with 2 fields: name of node to order before second name

getPrimaryItem() public method

{@inheritDoc}
public getPrimaryItem ( )

getPrimaryNodeType() public method

{@inheritDoc}
public getPrimaryNodeType ( )

getProperties() public method

{@inheritDoc}
public getProperties ( $nameFilter = null )

getPropertiesForStoreDeletedNode() public method

This method is only meant for the transport to be able to still build a store request for afterwards deleted nodes to support the operationslog.
See also: Jackalope\Transport\WritingInterface::storeNodes
public getPropertiesForStoreDeletedNode ( ) : Property[]
return Property[] with just the jcr:primaryType property in it

getPropertiesValues() public method

{@inheritDoc}
public getPropertiesValues ( $nameFilter = null, $dereference = true )

getProperty() public method

{@inheritDoc}
public getProperty ( $relPath )

getPropertyValue() public method

{@inheritDoc}
public getPropertyValue ( $name, $type = null )

getPropertyValueWithDefault() public method

{@inheritDoc}
public getPropertyValueWithDefault ( $relPath, $defaultValue )

getReferences() public method

{@inheritDoc}
public getReferences ( $name = null )

getSharedSet() public method

{@inheritDoc}
public getSharedSet ( )

getWeakReferences() public method

{@inheritDoc}
public getWeakReferences ( $name = null )

hasNode() public method

{@inheritDoc}
public hasNode ( $relPath )

hasNodes() public method

{@inheritDoc}
public hasNodes ( )

hasProperties() public method

{@inheritDoc}
public hasProperties ( )

hasProperty() public method

{@inheritDoc}
public hasProperty ( $relPath )

isCheckedOut() public method

{@inheritDoc}
public isCheckedOut ( )

isLocked() public method

{@inheritDoc}
public isLocked ( )

isNodeType() public method

{@inheritDoc}
public isNodeType ( $nodeTypeName )

needsChildReordering() public method

Determine whether the children of this node need to be reordered
public needsChildReordering ( ) : boolean
return boolean

orderBefore() public method

{@inheritDoc} Jackalope has no implementation-specific ordering restriction so no \PHPCR\ConstraintViolationException is expected. VersionException and LockException are not tested immediately but thrown on save.
public orderBefore ( $srcChildRelPath, $destChildRelPath )

refresh() protected method

{@inheritDoc} This is also called internally to refresh when the node is accessed in state DIRTY.
See also: Item::checkState
protected refresh ( $keepChanges, $internal = false )

remove() public method

{@inheritDoc} A jackalope node needs to notify the parent node about this if it is cached, in addition to \PHPCR\ItemInterface::remove()
public remove ( )

removeMixin() public method

{@inheritDoc}
public removeMixin ( $mixinName )

removeShare() public method

{@inheritDoc}
public removeShare ( )

removeSharedSet() public method

{@inheritDoc}
public removeSharedSet ( )

rename() public method

{@inheritDoc}
public rename ( $newName )

rollbackTransaction() public method

Additionally, notifies all properties of this node. Child nodes are not notified, it is the job of the ObjectManager to know which nodes are cached and notify them.
public rollbackTransaction ( )

setChildrenDirty() public method

Mark all cached children as dirty.
public setChildrenDirty ( )

setDeleted() public method

They will be automatically deleted by the backend, but the user might still have a reference to one of the property objects.
public setDeleted ( )

setDirty() public method

Overwrite to set the properties dirty as well.
public setDirty ( $keepChanges = false, $targetState = false )

setMixins() public method

{@inheritDoc}
public setMixins ( array $mixinNames )
$mixinNames array

setPath() public method

In addition to calling parent method, tell all properties
public setPath ( $path, $move = false )

setPrimaryType() public method

{@inheritDoc} Jackalope only validates type conflicts on save.
public setPrimaryType ( $nodeTypeName )

setProperty() public method

{@inheritDoc}
public setProperty ( $name, $value, $type = PropertyType::UNDEFINED, boolean $validate = true )
$validate boolean does the NodeType control throw an exception if the property can't be set? To use in case of UUID import

unsetChildNode() public method

Removes the reference in the internal node storage
public unsetChildNode ( string $name, boolean $check )
$name string the name of the child node to unset
$check boolean whether a state check should be done - set to false during internal update operations

unsetProperty() public method

Removes the reference in the internal node storage
public unsetProperty ( string $name )
$name string the name of the property to unset.

update() public method

{@inheritDoc}
public update ( $srcWorkspace )

Property Details

$definition protected_oe property

Cached instance of the node definition that defines this node
See also: Node::getDefinition()
protected NodeDefinitionInterface,PHPCR\NodeType $definition
return PHPCR\NodeType\NodeDefinitionInterface

$deletedProperties protected_oe property

this is needed in order to track deletions in case of refresh keys are the property names, values the properties (in state deleted)
protected $deletedProperties

$index protected_oe property

TODO: fully implement same-name siblings
protected int $index
return integer

$nodes protected_oe property

ordered list of the child node names
protected array $nodes
return array

$originalNodesOrder protected_oe property

used to calculate reordering operations if orderBefore() was used
protected array $originalNodesOrder
return array

$primaryType protected_oe property

The primary type name of this node
protected string $primaryType
return string

$properties protected_oe property

all properties are instantiated in the constructor OPTIMIZE: lazy instantiate property objects, just have local array of values
protected Property[],jackalope $properties
return Property[]