class NodeFactory (View source)

This factory creates nodes based on node data. Its main purpose is to assure that nodes created for a certain node data container and context are unique in memory.

Properties

protected Node[] $nodes
protected ObjectManagerInterface $objectManager
protected Context $securityContext
protected ContextFactoryInterface $contextFactory

Methods

createFromNodeData(NodeData $nodeData, Context $context)

Creates a node from the given NodeData container.

static array
getNodeInterfaceImplementations(ObjectManagerInterface $objectManager)

Get all NodeInterface implementations to check if a configured node class is in there.

filterNodeByContext(NodeInterface $node, Context $context)

Filter a node by the current context.

createContextMatchingNodeData(NodeData $nodeData)

Generates a Context that exactly fits the given NodeData Workspace and Dimensions.

void
reset()

Reset the node instances (for testing)

Details

NodeInterface createFromNodeData(NodeData $nodeData, Context $context)

Creates a node from the given NodeData container.

If this factory has previously created a Node for the given $node and it's dimensions, it will return the same node again.

Parameters

NodeData $nodeData
Context $context

Return Value

NodeInterface

Exceptions

NodeConfigurationException

static array getNodeInterfaceImplementations(ObjectManagerInterface $objectManager)

Get all NodeInterface implementations to check if a configured node class is in there.

Parameters

ObjectManagerInterface $objectManager

Return Value

array

protected NodeInterface|null filterNodeByContext(NodeInterface $node, Context $context)

Filter a node by the current context.

Will either return the node or NULL if it is not permitted in current context.

Parameters

NodeInterface $node
Context $context

Return Value

NodeInterface|null

Context createContextMatchingNodeData(NodeData $nodeData)

Generates a Context that exactly fits the given NodeData Workspace and Dimensions.

TODO: We could get more specific about removed and invisible content by adding some more logic here that generates fitting values.

Parameters

NodeData $nodeData

Return Value

Context

void reset()

Reset the node instances (for testing)

Return Value

void