public function addChild(NodeAbstract $node) { if (!$this->allowsNestingAndContent() && $this->hasContent()) { throw new Exception('A node cannot have both content and nested nodes'); } if (null !== ($parent = $node->getParent())) { $parent->removeChild($node); } $prev = end($this->childs) ?: null; $this->childs[] = $node; $node->setParent($this); if ($prev) { $prev->setNextSibling($node); } $node->setPreviousSibling($prev); $node->setNextSibling(null); }
protected function getParentTag(NodeAbstract $node) { if (null !== ($parent = $node->getParent())) { if ($parent instanceof Tag) { return $parent; } } }