createSingleNodeData() public method

Creates, adds and returns a child node of this node, without setting default properties or creating subnodes.
public createSingleNodeData ( string $name, NodeType $nodeType = null, string $identifier = null, Workspace $workspace = null, array $dimensions = null ) : NodeData
$name string Name of the new node
$nodeType NodeType Node type of the new node (optional)
$identifier string The identifier of the node, unique within the workspace, optional(!)
$workspace Workspace
$dimensions array An array of dimension name to dimension values
return NodeData
Esempio n. 1
0
 /**
  * Creates, adds and returns a child node of this node, without setting default
  * properties or creating subnodes. Only used internally.
  *
  * For internal use only!
  * TODO: New SiteImportService uses createNode() and DQL. When we drop the LegagcySiteImportService we can change this to protected.
  *
  * @param string $name Name of the new node
  * @param NodeType $nodeType Node type of the new node (optional)
  * @param string $identifier The identifier of the node, unique within the workspace, optional(!)
  * @return Node
  * @throws NodeConstraintException
  */
 public function createSingleNode($name, NodeType $nodeType = null, $identifier = null)
 {
     if ($nodeType !== null && !$this->willChildNodeBeAutoCreated($name) && !$this->isNodeTypeAllowedAsChildNode($nodeType)) {
         throw new NodeConstraintException('Cannot create new node "' . $name . '" of Type "' . $nodeType->getName() . '" in ' . $this->__toString(), 1400782413);
     }
     $dimensions = $this->context->getTargetDimensionValues();
     $nodeData = $this->nodeData->createSingleNodeData($name, $nodeType, $identifier, $this->context->getWorkspace(), $dimensions);
     $node = $this->nodeFactory->createFromNodeData($nodeData, $this->context);
     $this->context->getFirstLevelNodeCache()->flush();
     $this->emitNodeAdded($node);
     return $node;
 }