Returns a node specified by the given relative path.
/** * @test */ public function moveAfterInPersonalWorkspaceDoesNotAffectLiveWorkspace() { // move "teaser" after "main/dummy42" $teaserTestWorkspace = $this->nodeInTestWorkspace->getNode('teaser'); $teaserTestWorkspace->moveAfter($this->nodeInTestWorkspace->getNode('main/dummy42')); $this->assertNull($this->nodeInTestWorkspace->getNode('teaser/dummy42a'), 'moving not successful (1)'); $this->assertNotNull($this->nodeInTestWorkspace->getNode('main/teaser/dummy42a'), 'moving not successful (2)'); $this->assertNotNull($this->node->getNode('teaser'), 'moving shined through into live workspace (1)'); $this->assertNotNull($this->node->getNode('teaser/dummy42a'), 'moving shined through into live workspace (2)'); $this->assertNull($this->node->getNode('main/teaser/dummy42a'), 'moving shined through into live workspace (3)'); }
/** * Set up the following node structure: * * /headline (Neos.ContentRepository.Testing:Headline) * - live workspace * - title: Hello World * - personal workspace * - title: Hello World * - subtitle: Brave new world * /headline with language=de_DE * - personal workspace * - title: Hallo Welt * @return void */ protected function setupNodeWithShadowNodeInPersonalWorkspace() { $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); $headlineNode = $this->rootNodeInLiveWorkspace->createNode('headline', $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Headline')); $headlineNode->setProperty('title', 'Hello World'); $headlineNodeInPersonalWorkspace = $this->rootNodeInPersonalWorkspace->getNode('headline'); $headlineNodeInPersonalWorkspace->setProperty('subtitle', 'Brave new world'); $germanContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName, 'dimensions' => array('language' => array('de_DE', 'mul_ZZ')))); $headlineInGerman = $germanContext->getNode('/headline'); $headlineInGerman->setProperty('title', 'Hallo Welt'); $this->flushNodeChanges(); }
/** * Check if the given node is already a collection, find collection by nodePath otherwise, throw exception * if no content collection could be found * * @param NodeInterface $node * @param string $nodePath * @return NodeInterface * @throws Exception */ public function nearestContentCollection(NodeInterface $node, $nodePath) { $contentCollectionType = 'Neos.Neos:ContentCollection'; if ($node->getNodeType()->isOfType($contentCollectionType)) { return $node; } else { if ((string) $nodePath === '') { throw new Exception(sprintf('No content collection of type %s could be found in the current node and no node path was provided. You might want to configure the nodePath property with a relative path to the content collection.', $contentCollectionType), 1409300545); } $subNode = $node->getNode($nodePath); if ($subNode !== null && $subNode->getNodeType()->isOfType($contentCollectionType)) { return $subNode; } else { throw new Exception(sprintf('No content collection of type %s could be found in the current node (%s) or at the path "%s". You might want to adjust your node type configuration and create the missing child node through the "flow node:repair --node-type %s" command.', $contentCollectionType, $node->getPath(), $nodePath, (string) $node->getNodeType()), 1389352984); } } }
/** * Internal method to do the actual copying. * * For behavior of the $detachedCopy parameter, see method Node::createRecursiveCopy(). * * @param NodeInterface $referenceNode * @param $nodeName * @param boolean $detachedCopy * @return NodeInterface * @throws NodeConstraintException * @throws NodeExistsException */ protected function copyIntoInternal(NodeInterface $referenceNode, $nodeName, $detachedCopy) { if ($referenceNode->getNode($nodeName) !== null) { throw new NodeExistsException('Node with path "' . $referenceNode->getPath() . '/' . $nodeName . '" already exists.', 1292503467); } // On copy we basically re-recreate an existing node on a new location. As we skip the constraints check on // node creation we should do the same while writing the node on the new location. if (!$referenceNode->willChildNodeBeAutoCreated($nodeName) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) { throw new NodeConstraintException(sprintf('Cannot copy "%s" into "%s" due to node type constraints.', $this->__toString(), $referenceNode->__toString()), 1404648177); } $copiedNode = $this->createRecursiveCopy($referenceNode, $nodeName, $detachedCopy); $this->context->getFirstLevelNodeCache()->flush(); $this->emitNodeAdded($copiedNode); return $copiedNode; }