/**
  * 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;
 }
예제 #2
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: Check if we can change the import service to avoid making this public.
  *
  * @param string $name Name of the new node
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType Node type of the new node (optional)
  * @param string $identifier The identifier of the node, unique within the workspace, optional(!)
  * @param array $dimensions Content dimension values to set on the node (Array of dimension names to array of values)
  * @return \TYPO3\TYPO3CR\Domain\Model\Node
  */
 public function createSingleNode($name, NodeType $nodeType = NULL, $identifier = NULL, array $dimensions = NULL)
 {
     if ($dimensions === NULL || $dimensions === array()) {
         $targetDimensions = $this->context->getTargetDimensions();
         $dimensions = array_map(function ($value) {
             return array($value);
         }, $targetDimensions);
     }
     $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;
 }