Neos\ContentRepository\Domain\Repository\NodeDataRepository::findShadowNodeByPath PHP Метод

findShadowNodeByPath() публичный Метод

Find a shadow node by exact path
public findShadowNodeByPath ( string $path, Workspace $workspace, array $dimensions = null ) : NodeData | null
$path string
$workspace Neos\ContentRepository\Domain\Model\Workspace
$dimensions array
Результат Neos\ContentRepository\Domain\Model\NodeData | null
    public function findShadowNodeByPath($path, Workspace $workspace, array $dimensions = null)
    {
        $workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
        $nodes = $this->findRawNodesByPath($path, $workspace, $dimensions, true);
        $dimensions = $dimensions === null ? [] : $dimensions;
        $foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($nodes, $workspaces, $dimensions);
        $foundNodes = $this->filterRemovedNodes($foundNodes, true);
        if ($foundNodes !== []) {
            return reset($foundNodes);
        }
        return null;
    }

Usage Example

 /**
  * @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());
 }