‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\Form\NodeFactory Class Reference

Public Member Functions

 __construct ()
 
 create (array $data)
 

Private Member Functions

 registerAdditionalNodeTypesFromConfiguration ()
 
 registerNodeResolvers ()
 
 initializeNodeClass (string $className, array $data)
 
 initializeNodeResolverClass (string $className, array $data)
 

Private Attributes

array $nodeResolver = []
 
array $nodeTypes
 

Detailed Description

Create an element object depending on renderType.

This is the main factory to instantiate any node within the render chain of FormEngine. All nodes must implement NodeInterface.

Nodes are "container" classes of the render chain, "element" classes that render single elements, as well as "fieldWizard", "fieldInformation" and "fieldControl" classes which are called by single elements to enrich them.

This factory gets a string "renderType" and then looks up in a list which specific class should handle this renderType. This list can be extended with own renderTypes by extensions, existing renderTypes can be overridden, and

  • for complex cases - it is possible to register own resolver classes for single renderTypes that can return a node class name to override the default lookup list.

    Todo:
    ‪: Declare final in v13. May require adding an interface to allow mocking in tests

Definition at line 39 of file NodeFactory.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Form\NodeFactory::__construct ( )

Set up factory. Initialize additionally registered nodes.

Definition at line 143 of file NodeFactory.php.

References TYPO3\CMS\Backend\Form\NodeFactory\registerAdditionalNodeTypesFromConfiguration(), and TYPO3\CMS\Backend\Form\NodeFactory\registerNodeResolvers().

Member Function Documentation

◆ create()

TYPO3\CMS\Backend\Form\NodeFactory::create ( array  $data)

Create a node depending on type

Parameters
array$data‪All information to decide which class should be instantiated and given down to sub nodes
Exceptions
Exception

Definition at line 155 of file NodeFactory.php.

References TYPO3\CMS\Backend\Form\NodeFactory\initializeNodeClass(), and TYPO3\CMS\Backend\Form\NodeFactory\initializeNodeResolverClass().

◆ initializeNodeClass()

TYPO3\CMS\Backend\Form\NodeFactory::initializeNodeClass ( string  $className,
array  $data 
)
private

Instantiate a NodeInterface class and set data.

Parameters
array$data‪Main data array

Definition at line 277 of file NodeFactory.php.

Referenced by TYPO3\CMS\Backend\Form\NodeFactory\create().

◆ initializeNodeResolverClass()

TYPO3\CMS\Backend\Form\NodeFactory::initializeNodeResolverClass ( string  $className,
array  $data 
)
private

Instantiate a NodeResolverInterface class and set data.

Parameters
array$data‪Main data array

Definition at line 290 of file NodeFactory.php.

Referenced by TYPO3\CMS\Backend\Form\NodeFactory\create().

◆ registerAdditionalNodeTypesFromConfiguration()

TYPO3\CMS\Backend\Form\NodeFactory::registerAdditionalNodeTypesFromConfiguration ( )
private

Add node types from nodeRegistry to $this->nodeTypes. This can be used to add new render types or to overwrite existing node types. The registered class must implement the NodeInterface and will be called if a node with this renderType is rendered.

Exceptions
Exception‪if configuration is incomplete or two nodes with identical priorities are registered

Definition at line 195 of file NodeFactory.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Form\NodeFactory\__construct().

◆ registerNodeResolvers()

TYPO3\CMS\Backend\Form\NodeFactory::registerNodeResolvers ( )
private

Add resolver and add them sorted to a local property. This can be used to manipulate the nodeName to class resolution with own code.

Exceptions
Exception‪if configuration is incomplete or two resolver with identical priorities are registered

Definition at line 238 of file NodeFactory.php.

References $GLOBALS, and TYPO3\CMS\Backend\Form\NodeFactory\$nodeResolver.

Referenced by TYPO3\CMS\Backend\Form\NodeFactory\__construct().

Member Data Documentation

◆ $nodeResolver

array TYPO3\CMS\Backend\Form\NodeFactory::$nodeResolver = []
private

Node resolver classes Nested array with nodeName as key, (sorted) priority as sub key and class as value

Definition at line 45 of file NodeFactory.php.

Referenced by TYPO3\CMS\Backend\Form\NodeFactory\registerNodeResolvers().

◆ $nodeTypes

array TYPO3\CMS\Backend\Form\NodeFactory::$nodeTypes
private

Default registry of node name to handling class

Definition at line 50 of file NodeFactory.php.