PHP Class Jackalope\NodeType\NodeTypeManager

In Jackalope, we try to do lazy fetching of node types to reduce overhead. Jackalope supports registering node types, and when using the jackrabbit for transport, there is an additional method registerNodeTypesCnd for the jackrabbit specific textual node type specification
Inheritance: implements IteratorAggregat\IteratorAggregate, implements PHPCR\NodeType\NodeTypeManagerInterface
Show file Open project: jackalope/jackalope Class Usage Examples

Protected Properties

Property Type Description
$factory Jackalope\FactoryInterface The factory to instantiate objects.
$fetchedAllFromBackend boolean Methods like hasNodeType() need to fetch all node types. Others like getNodeType() do not need all, but just the requested one. Unless we need all, we only load specific ones and cache them.
$mixinTypes array Cache of already fetched mixin node type instances.
$namespaceRegistry PHPCR\NamespaceRegistryInterface
$nodeTree array Array of arrays with the super type as key and its sub types as values.
$objectManager Jackalope\ObjectManager
$primaryTypes array Cache of already fetched primary node type instances.

Public Methods

Method Description
__construct ( Jackalope\FactoryInterface $factory, ObjectManager $objectManager, PHPCR\NamespaceRegistryInterface $namespaceRegistry ) Create the node type manager for a session.
createNodeDefinitionTemplate ( ) {@inheritDoc}
createNodeTypeTemplate ( $ntd = null ) {@inheritDoc}
createPropertyDefinitionTemplate ( ) {@inheritDoc}
getAllNodeTypes ( ) {@inheritDoc}
getDeclaredSubtypes ( string $nodeTypeName ) : array Helper method for node types: Returns the declared subtypes of a given nodename.
getIterator ( ) : Iterator Provide Traversable interface: redirect to getAllNodeTypes
getMixinNodeTypes ( ) {@inheritDoc}
getNodeType ( $nodeTypeName ) {@inheritDoc}
getPrimaryNodeTypes ( ) {@inheritDoc}
getSubtypes ( string $nodeTypeName ) : array Helper method for NodeType: Returns all sub types of a node and their sub types.
hasNodeType ( $name ) {@inheritDoc}
registerNodeType ( PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, $allowUpdate ) {@inheritDoc}
registerNodeTypes ( array $definitions, $allowUpdate ) {@inheritDoc}
registerNodeTypesCnd ( $cnd, $allowUpdate ) {@inheritDoc}
unregisterNodeType ( $name ) {@inheritDoc}
unregisterNodeTypes ( array $names ) {@inheritDoc}

Protected Methods

Method Description
addNodeType ( PHPCR\NodeType\NodeTypeInterface $nodeType ) Stores the node type in our internal structures (flat && tree)
createNodeType ( PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, boolean $allowUpdate ) : NodeType Internally create a node type object
fetchNodeTypes ( string $name = null ) Fetch a node type from backend.

Private Methods

Method Description
addToNodeTree ( PHPCR\NodeType\NodeTypeInterface $nodetype ) Adds the declared super types of a node type to the tree to be able to fetch the sub types of those super types later on.

Method Details

__construct() public method

There may be only one instance per session
public __construct ( Jackalope\FactoryInterface $factory, ObjectManager $objectManager, PHPCR\NamespaceRegistryInterface $namespaceRegistry )
$factory Jackalope\FactoryInterface
$objectManager Jackalope\ObjectManager
$namespaceRegistry PHPCR\NamespaceRegistryInterface

addNodeType() protected method

Stores the node type in our internal structures (flat && tree)
protected addNodeType ( PHPCR\NodeType\NodeTypeInterface $nodeType )
$nodeType PHPCR\NodeType\NodeTypeInterface The nodetype to add

createNodeDefinitionTemplate() public method

{@inheritDoc}

createNodeType() protected method

Internally create a node type object
protected createNodeType ( PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, boolean $allowUpdate ) : NodeType
$ntd PHPCR\NodeType\NodeTypeDefinitionInterface
$allowUpdate boolean whether updating the definition is to be allowed or not
return NodeType the new node type

createNodeTypeTemplate() public method

{@inheritDoc}
public createNodeTypeTemplate ( $ntd = null )

createPropertyDefinitionTemplate() public method

{@inheritDoc}

fetchNodeTypes() protected method

Without a filter parameter, this will fetch all node types from the backend. It is no problem to call this method with null as name, it will remember once it fetched all node types and do nothing after that. On fetch all, already cached node types are kept.
protected fetchNodeTypes ( string $name = null )
$name string type name to fetch. defaults to null which will fetch all nodes.

getAllNodeTypes() public method

{@inheritDoc}
public getAllNodeTypes ( )

getDeclaredSubtypes() public method

Helper method for node types: Returns the declared subtypes of a given nodename.
See also: NodeType::getDeclaredSubtypes
public getDeclaredSubtypes ( string $nodeTypeName ) : array
$nodeTypeName string
return array with the names of the subnode types pointing to the node type instances

getIterator() public method

Provide Traversable interface: redirect to getAllNodeTypes
public getIterator ( ) : Iterator
return Iterator over all node types

getMixinNodeTypes() public method

{@inheritDoc}
public getMixinNodeTypes ( )

getNodeType() public method

{@inheritDoc}
public getNodeType ( $nodeTypeName )

getPrimaryNodeTypes() public method

{@inheritDoc}
public getPrimaryNodeTypes ( )

getSubtypes() public method

Helper method for NodeType: Returns all sub types of a node and their sub types.
See also: NodeType::getSubtypes
public getSubtypes ( string $nodeTypeName ) : array
$nodeTypeName string
return array with the names of the subnode types pointing to the node type instances

hasNodeType() public method

{@inheritDoc}
public hasNodeType ( $name )

registerNodeType() public method

{@inheritDoc}
public registerNodeType ( PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, $allowUpdate )
$ntd PHPCR\NodeType\NodeTypeDefinitionInterface

registerNodeTypes() public method

{@inheritDoc}
public registerNodeTypes ( array $definitions, $allowUpdate )
$definitions array

registerNodeTypesCnd() public method

{@inheritDoc}
public registerNodeTypesCnd ( $cnd, $allowUpdate )

unregisterNodeType() public method

{@inheritDoc}
public unregisterNodeType ( $name )

unregisterNodeTypes() public method

{@inheritDoc}
public unregisterNodeTypes ( array $names )
$names array

Property Details

$factory protected property

The factory to instantiate objects.
protected FactoryInterface,Jackalope $factory
return Jackalope\FactoryInterface

$fetchedAllFromBackend protected property

Methods like hasNodeType() need to fetch all node types. Others like getNodeType() do not need all, but just the requested one. Unless we need all, we only load specific ones and cache them.
protected bool $fetchedAllFromBackend
return boolean

$mixinTypes protected property

Cache of already fetched mixin node type instances.
protected array $mixinTypes
return array

$namespaceRegistry protected property

protected NamespaceRegistryInterface,PHPCR $namespaceRegistry
return PHPCR\NamespaceRegistryInterface

$nodeTree protected property

Array of arrays with the super type as key and its sub types as values.
protected array $nodeTree
return array

$objectManager protected property

protected ObjectManager,Jackalope $objectManager
return Jackalope\ObjectManager

$primaryTypes protected property

Cache of already fetched primary node type instances.
protected array $primaryTypes
return array