Returns the parent node of this node
public getParent ( ) : Neos\ContentRepository\Domain\Model\NodeInterface | ||
Résultat | Neos\ContentRepository\Domain\Model\NodeInterface | The parent node or NULL if this is the root node |
/** * @param NodeInterface $contextNode The node for which the preceding node should be found * @return NodeInterface The preceding node of $contextNode or NULL */ protected function getPrevForNode($contextNode) { $nodesInContext = $contextNode->getParent()->getChildNodes(); for ($i = 0; $i < count($nodesInContext) - 1; $i++) { if ($nodesInContext[$i + 1] === $contextNode) { return $nodesInContext[$i]; } } return null; }
/** * @param NodeInterface $contextNode The node for which the preceding node should be found * @return NodeInterface The preceding nodes of $contextNode or NULL */ protected function getPrevForNode(NodeInterface $contextNode) { $nodesInContext = $contextNode->getParent()->getChildNodes(); $count = count($nodesInContext) - 1; for ($i = $count; $i > 0; $i--) { if ($nodesInContext[$i] === $contextNode) { unset($nodesInContext[$i]); return array_values($nodesInContext); } else { unset($nodesInContext[$i]); } } return null; }
protected function getParents(NodeInterface $contextNode, NodeInterface $siteNode) { $parents = array(); while ($contextNode !== $siteNode && $contextNode->getParent() !== null) { $contextNode = $contextNode->getParent(); $parents[] = $contextNode; } return $parents; }
/** * Collects metadata attributes used to allow editing of the node in the Neos backend. * * @param array $attributes * @param NodeInterface $node * @return array */ protected function addGenericEditingMetadata(array $attributes, NodeInterface $node) { $attributes['typeof'] = 'typo3:' . $node->getNodeType()->getName(); $attributes['about'] = $node->getContextPath(); $attributes['data-node-_identifier'] = $node->getIdentifier(); $attributes['data-node-__workspace-name'] = $node->getWorkspace()->getName(); $attributes['data-node-__label'] = $node->getLabel(); if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) { $attributes['rel'] = 'typo3:content-collection'; } // these properties are needed together with the current NodeType to evaluate Node Type Constraints // TODO: this can probably be greatly cleaned up once we do not use CreateJS or VIE anymore. if ($node->getParent()) { $attributes['data-node-__parent-node-type'] = $node->getParent()->getNodeType()->getName(); } if ($node->isAutoCreated()) { $attributes['data-node-_name'] = $node->getName(); $attributes['data-node-_is-autocreated'] = 'true'; } if ($node->getParent() && $node->getParent()->isAutoCreated()) { $attributes['data-node-_parent-is-autocreated'] = 'true'; // we shall only add these properties if the parent is actually auto-created; as the Node-Type-Switcher in the UI relies on that. $attributes['data-node-__parent-node-name'] = $node->getParent()->getName(); $attributes['data-node-__grandparent-node-type'] = $node->getParent()->getParent()->getNodeType()->getName(); } return $attributes; }
/** * @param NodeInterface $targetNode * @param string $position * @return NodeInterface */ protected function getDesignatedParentNode(NodeInterface $targetNode, $position) { $referenceNode = $targetNode; if (in_array($position, array('before', 'after'))) { $referenceNode = $targetNode->getParent(); } return $referenceNode; }
/** * Copies this node after the given node * * @param NodeInterface $referenceNode * @param string $nodeName * @return NodeInterface * @throws NodeExistsException * @throws NodeConstraintException * @api */ public function copyAfter(NodeInterface $referenceNode, $nodeName) { if ($referenceNode->getParent()->getNode($nodeName) !== null) { throw new NodeExistsException('Node with path "' . $referenceNode->getParent()->getPath() . '/' . $nodeName . '" already exists.', 1292503466); } if (!$referenceNode->getParent()->isNodeTypeAllowedAsChildNode($this->getNodeType())) { throw new NodeConstraintException('Cannot copy ' . $this->__toString() . ' after ' . $referenceNode->__toString(), 1404648170); } $this->emitBeforeNodeCopy($this, $referenceNode->getParent()); $copiedNode = $this->createRecursiveCopy($referenceNode->getParent(), $nodeName, $this->getNodeType()->isAggregate()); $copiedNode->moveAfter($referenceNode); $this->context->getFirstLevelNodeCache()->flush(); $this->emitNodeAdded($copiedNode); $this->emitAfterNodeCopy($copiedNode, $referenceNode->getParent()); return $copiedNode; }