Creates, adds and returns a child node of this node. Also sets default
properties and creates default subnodes.
public createNode ( string $name, |
||
$name | string | Name of the new node |
$nodeType | Node type of the new node (optional) | |
$identifier | string | The identifier of the node, unique within the workspace, optional(!) |
return |
/** * @test */ public function inheritanceBasedConstraintsWork() { $testingNodeTypeWithSubnodes = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithSubnodes'); $testingNodeTypeThatInheritsFromDocumentType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Page'); $nodeWithChildNode = $this->rootNode->createNode('node-with-child-node', $testingNodeTypeWithSubnodes); $nodeWithChildNode->createNode('page', $testingNodeTypeThatInheritsFromDocumentType); $this->assertCount(2, $nodeWithChildNode->getChildNodes()); }
/** * Set up the following node structure: * * /headline (Neos.ContentRepository.Testing:Headline) * - live workspace * - title: Hello World * - personal workspace * - title: Hello World * - subtitle: Brave new world * /headline with language=de_DE * - personal workspace * - title: Hallo Welt * @return void */ protected function setupNodeWithShadowNodeInPersonalWorkspace() { $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); $headlineNode = $this->rootNodeInLiveWorkspace->createNode('headline', $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Headline')); $headlineNode->setProperty('title', 'Hello World'); $headlineNodeInPersonalWorkspace = $this->rootNodeInPersonalWorkspace->getNode('headline'); $headlineNodeInPersonalWorkspace->setProperty('subtitle', 'Brave new world'); $germanContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName, 'dimensions' => array('language' => array('de_DE', 'mul_ZZ')))); $headlineInGerman = $germanContext->getNode('/headline'); $headlineInGerman->setProperty('title', 'Hallo Welt'); $this->flushNodeChanges(); }