Neos\ContentRepository\Domain\Factory\NodeFactory::createContextMatchingNodeData PHP Метод

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

TODO: We could get more specific about removed and invisible content by adding some more logic here that generates fitting values.
public createContextMatchingNodeData ( NodeData $nodeData ) : Context
$nodeData Neos\ContentRepository\Domain\Model\NodeData
Результат Neos\ContentRepository\Domain\Service\Context
    public function createContextMatchingNodeData(NodeData $nodeData)
    {
        return $this->contextFactory->create(array('workspaceName' => $nodeData->getWorkspace()->getName(), 'invisibleContentShown' => true, 'inaccessibleContentShown' => true, 'removedContentShown' => true, 'dimensions' => $nodeData->getDimensionValues()));
    }

Usage Example

 /**
  * @test
  */
 public function createContextMatchingNodeDataCreatesMatchingContext()
 {
     $dimensionValues = array('language' => array('is'));
     $workspaceName = 'some-workspace';
     $mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $mockWorkspace = $this->getMockBuilder(Workspace::class)->setMockClassName('MockWorkspace')->disableOriginalConstructor()->getMock();
     $mockWorkspace->expects(self::any())->method('getName')->will(self::returnValue($workspaceName));
     $mockContextFactory = $this->createMock(ContextFactoryInterface::class);
     $mockContextFactory->expects(self::once())->method('create')->with(array('workspaceName' => $workspaceName, 'invisibleContentShown' => true, 'inaccessibleContentShown' => true, 'removedContentShown' => true, 'dimensions' => $dimensionValues))->willReturn($mockContext);
     $this->inject($this->nodeFactory, 'contextFactory', $mockContextFactory);
     $mockNodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
     $mockNodeData->expects(self::any())->method('getWorkspace')->will($this->returnValue($mockWorkspace));
     $mockNodeData->expects(self::any())->method('getDimensionValues')->willReturn($dimensionValues);
     $context = $this->nodeFactory->createContextMatchingNodeData($mockNodeData);
     self::assertEquals($mockContext, $context);
 }
All Usage Examples Of Neos\ContentRepository\Domain\Factory\NodeFactory::createContextMatchingNodeData