示例#1
0
 /**
  * Adopts a node from a (possibly) different context to this context
  *
  * Check if a node variant already exists for this context and return it if found. Otherwise a new node variant for
  * this context is created.
  *
  * @param NodeInterface $node The node with a different context. If the context of the given node is the same as this context the operation will have no effect.
  * @return NodeInterface A new or existing node that matches this context
  */
 public function adoptNode(NodeInterface $node)
 {
     if ($node->getContext() === $this) {
         return $node;
     }
     $existingNode = $this->getNodeByIdentifier($node->getIdentifier());
     if ($existingNode !== NULL) {
         return $existingNode;
     }
     return $node->createVariantForContext($this);
 }