/**
  * Creates a new text node with the given parent and text string.
  *
  * @param $parent  the parent of the text node
  * @param $string  the text of the text node
  *
  * @return TextNode the newly created TextNode
  */
 protected function createTextNode(ElementNode $parent, $string)
 {
     if (count($parent->getChildren())) {
         $children = $parent->getChildren();
         $lastElement = end($children);
         reset($children);
         if ($lastElement->isTextNode()) {
             $lastElement->setValue($lastElement->getValue() . $string);
             return $lastElement;
         }
     }
     $textNode = new $this->textNodeClassName($string);
     $textNode->setNodeId(++$this->nextNodeid);
     $parent->addChild($textNode);
     return $textNode;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new text node with the given parent and text string.
  *
  * @param $parent  the parent of the text node
  * @param $string  the text of the text node
  *
  * @return the newly created TextNode
  */
 protected function createTextNode(ElementNode $parent, $string)
 {
     $textNode = new TextNode($string);
     $textNode->setNodeId(++$this->nextNodeid);
     $parent->addChild($textNode);
     return $textNode;
 }
Ejemplo n.º 3
0
 /**
  * Creates a new text node with the given parent and text string.
  *
  * @param ElementNode $parent  the parent of the text node
  * @param string $string  the text of the text node
  *
  * @return TextNode the newly created TextNode
  */
 protected function createTextNode(ElementNode $parent, $string)
 {
     $children = $parent->getChildren();
     if (!empty($children)) {
         $lastElement = end($children);
         reset($children);
         if ($lastElement->isTextNode()) {
             $lastElement->setValue($lastElement->getValue() . $string);
             return $lastElement;
         }
     }
     $textNode = new TextNode($string);
     $parent->addChild($textNode);
     return $textNode;
 }