getNode() public method

Returns a node specified by the given relative path.
public getNode ( string $path ) : Neos\ContentRepository\Domain\Model\NodeInterface
$path string Path specifying the node, relative to this node
return Neos\ContentRepository\Domain\Model\NodeInterface The specified node or NULL if no such node exists
コード例 #1
0
 /**
  * @test
  */
 public function aSingleNodeExportedWithNodeDataExportCanBeImportedWithNodeDataImport()
 {
     $originalNode = $this->rootNode->createNode('foo', $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:ImportExport'));
     $originalNode->setProperty('description', 'Some node with a property');
     $originalNode->setProperty('someDate', new \DateTime());
     $this->persistenceManager->persistAll();
     $exportService = new NodeExportService();
     $xml = $exportService->export('/')->outputMemory();
     $this->nodeDataRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->saveNodesAndTearDownRootNodeAndRepository();
     $this->setUpRootNodeAndRepository();
     $importService = new NodeImportService();
     $reader = new \XMLReader();
     $reader->XML($xml);
     $importService->import($reader, '/');
     $importedNode = $this->rootNode->getNode('foo');
     $this->assertNotNull($importedNode, 'Expected node not found');
     $this->assertSame($originalNode->getIdentifier(), $importedNode->getIdentifier());
     $this->assertSame($originalNode->getProperty('description'), $importedNode->getProperty('description'));
     $this->assertEquals($originalNode->getProperty('someDate'), $importedNode->getProperty('someDate'));
 }
コード例 #2
0
 /**
  * @test
  */
 public function changedNodeCanBePublishedFromPersonalToLiveWorkspace()
 {
     $liveContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $liveContext->getRootNode()->createNode('homepage')->createNode('teaser')->createNode('node52697bdfee199');
     $teaserNode = $this->rootNode->getNode('/homepage/teaser/node52697bdfee199');
     $teaserNode->setProperty('text', 'Updated text!');
     $this->saveNodesAndTearDownRootNodeAndRepository();
     $this->setUpRootNodeAndRepository();
     $this->rootNode->getWorkspace()->publishNode($teaserNode, $this->liveWorkspace);
     $this->saveNodesAndTearDownRootNodeAndRepository();
     $this->setUpRootNodeAndRepository();
     $liveContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $liveRootNode = $liveContext->getRootNode();
     $teaserNode = $liveRootNode->getNode('/homepage/teaser/node52697bdfee199');
     $this->assertInstanceOf(NodeInterface::class, $teaserNode);
 }
コード例 #3
0
 /**
  * @test
  */
 public function nodeFromLiveWorkspaceMovedInUserWorkspaceRetainsShadowNodeInGroupWorkspace()
 {
     $liveContext = $this->contextFactory->create([]);
     $liveContext->getRootNode()->createNode('foo')->createNode('bar')->createNode('baz');
     $this->persistenceManager->persistAll();
     $this->rootNode->getNode('foo/bar/baz')->moveInto($this->rootNode->getNode('foo'));
     $this->persistenceManager->persistAll();
     $this->rootNode->getContext()->getWorkspace()->publish($this->groupWorkspace);
     $this->persistenceManager->persistAll();
     $groupContext = $this->contextFactory->create(['workspaceName' => $this->currentGroupWorkspace]);
     $movedBazNode = $groupContext->getRootNode()->getNode('foo')->getNode('baz');
     $this->assertInstanceOf(NodeInterface::class, $movedBazNode);
     $shadowNode = $this->nodeDataRepository->findShadowNodeByPath('/foo/bar/baz', $this->groupWorkspace, $groupContext->getDimensions());
     $this->assertInstanceOf(NodeData::class, $shadowNode);
     $this->assertNotNull($shadowNode->getMovedTo());
     $this->assertTrue($shadowNode->isRemoved());
 }