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

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

Find a single node by exact path.
public findOneByPath ( string $path, Workspace $workspace, array $dimensions = null, boolean | null $removedNodes = false ) : NodeData
$path string Absolute path of the node
$workspace Neos\ContentRepository\Domain\Model\Workspace The containing workspace
$dimensions array An array of dimensions with array of ordered values to use for fallback matching
$removedNodes boolean | null Include removed nodes, NULL (all), FALSE (no removed nodes) or TRUE (only removed nodes)
Результат Neos\ContentRepository\Domain\Model\NodeData The matching node if found, otherwise NULL
    public function findOneByPath($path, Workspace $workspace, array $dimensions = null, $removedNodes = false)
    {
        if ($path === '/') {
            return $workspace->getRootNodeData();
        }
        $workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
        $nodes = $this->findRawNodesByPath($path, $workspace, $dimensions);
        $dimensions = $dimensions === null ? [] : $dimensions;
        $foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($nodes, $workspaces, $dimensions);
        $foundNodes = $this->filterNodeDataByBestMatchInContext($foundNodes, $workspace, $dimensions, $removedNodes);
        $foundNodes = $this->filterRemovedNodes($foundNodes, $removedNodes);
        if ($foundNodes !== []) {
            return reset($foundNodes);
        }
        return null;
    }

Usage Example

 /**
  * @test
  */
 public function findOneByPathFindsAddedNodeInRepositoryAndRespectsWorkspaceAndDimensions()
 {
     $liveWorkspace = new Workspace('live');
     $dimensions = ['persona' => ['everybody'], 'language' => ['de_DE', 'mul_ZZ']];
     $nodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
     $nodeData->expects($this->any())->method('getPath')->will($this->returnValue('/foo'));
     $nodeData->expects($this->any())->method('getWorkspace')->will($this->returnValue($liveWorkspace));
     $nodeData->expects($this->any())->method('getDimensionValues')->will($this->returnValue($dimensions));
     $nodeData->expects($this->atLeastOnce())->method('matchesWorkspaceAndDimensions')->with($liveWorkspace, $dimensions)->will($this->returnValue(true));
     $this->mockQuery->expects($this->any())->method('getResult')->will($this->returnValue([]));
     $this->nodeDataRepository->add($nodeData);
     $result = $this->nodeDataRepository->findOneByPath('/foo', $liveWorkspace, $dimensions);
     $this->assertSame($nodeData, $result);
 }
All Usage Examples Of Neos\ContentRepository\Domain\Repository\NodeDataRepository::findOneByPath