/** * Materializes the original node data (of a different workspace) into the current * workspace. * * @return void */ protected function materializeNodeData() { $dimensions = $this->context->getTargetDimensionValues(); $newNodeData = new NodeData($this->nodeData->getPath(), $this->context->getWorkspace(), $this->nodeData->getIdentifier(), $dimensions); $this->nodeDataRepository->add($newNodeData); $newNodeData->similarize($this->nodeData); $this->nodeData = $newNodeData; $this->nodeDataIsMatchingContext = true; $nodeType = $this->getNodeType(); foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) { $childNode = $this->getNode($childNodeName); if ($childNode instanceof Node && !$childNode->isNodeDataMatchingContext()) { $childNode->materializeNodeData(); } } }
/** * @test */ public function findByParentAndNodeTypeIncludesAddedNodeInRepositoryAndRespectsWorkspaceAndDimensions() { $liveWorkspace = new Workspace('live'); $nodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock(); $nodeData->expects($this->any())->method('getIdentifier')->will($this->returnValue('abcd-efgh-ijkl-mnop')); $nodeData->expects($this->any())->method('getPath')->will($this->returnValue('/foo/bar')); $nodeData->expects($this->any())->method('getDepth')->will($this->returnValue(2)); $this->nodeDataRepository->add($nodeData); $dimensions = array('persona' => array('everybody'), 'language' => array('de_DE', 'mul_ZZ')); $nodeData->expects($this->atLeastOnce())->method('matchesWorkspaceAndDimensions')->with($liveWorkspace, $dimensions)->will($this->returnValue(true)); $this->nodeDataRepository->expects($this->any())->method('getNodeDataForParentAndNodeType')->will($this->returnValue(array())); $this->nodeDataRepository->expects($this->once())->method('getNodeTypeFilterConstraintsForDql')->will($this->returnValue(array('excludeNodeTypes' => array(), 'includeNodeTypes' => array()))); $result = $this->nodeDataRepository->findByParentAndNodeType('/foo', null, $liveWorkspace, $dimensions); $this->assertCount(1, $result); $fetchedNodeData = reset($result); $this->assertSame($nodeData, $fetchedNodeData); }
/** * Initializes this workspace. * * If this workspace is brand new, a root node is created automatically. * * @param integer $initializationCause * @return void */ public function initializeObject($initializationCause) { if ($initializationCause === ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED) { $this->rootNodeData = new NodeData('/', $this); $this->nodeDataRepository->add($this->rootNodeData); if ($this->owner instanceof UserInterface) { $this->setOwner($this->owner); } } }