public function setContent($content, $type = 'text')
    {
        $type = (string) $type;
        $this->setType($type);
        $document = $this->getDomElement()->ownerDocument;

        if ('text' === $type || 'html' === $type) {
            $this->getDomElement()->nodeValue = (string) $content;
        } elseif ('xhtml' === $type) {
            if (!$content instanceof \DOMElement) {
                throw new \InvalidArgumentException('Content should be an instance of DOMElement');
            }
            Xhtml::import($content, $this->getDomElement());
        } elseif ($this->isXmlMimeType($type)) {
            if (!$content instanceof \DOMElement) {
                throw new \InvalidArgumentException('Content should be an instance of DOMElement');
            }
            $this->getDomElement()->appendChild($document->importNode($content, true));
        } elseif (stripos($type, 'text/') === 0) {
            $this->getDomElement()->nodeValue = (string) $content;
        } else {
            $this->getDomElement()->nodeValue = base64_encode($content);
        }
        $this->setCachedProperty('content', $content);
    }
public function setContent($content, $type = 'text')
    {
        $type = (string) $type;
        $this->setType($type);
        $document = $this->getDomElement()->ownerDocument;

        if ('text' === $type || 'html' === $type) {
            $this->getDomElement()->nodeValue = (string) $content;
        } elseif ('xhtml' === $type) {
            if (!$content instanceof \DOMElement) {
                throw new \InvalidArgumentException('Content should be an instance of DOMElement');
            }
            Xhtml::import($content, $this->getDomElement());
        } elseif ($this->isXmlMimeType($type)) {
            if (!$content instanceof \DOMElement) {
                throw new \InvalidArgumentException('Content should be an instance of DOMElement');
            }
            $this->getDomElement()->appendChild($document->importNode($content, true));
        } elseif (stripos($type, 'text/') === 0) {
            $this->getDomElement()->nodeValue = (string) $content;
        } else {
            $this->getDomElement()->nodeValue = base64_encode($content);
        }
        $this->setCachedProperty('content', $content);
    }
public function setContent ( $ content , $ type = 'text' ) { $ type = ( string ) $ type ; $ this -> setType ( $ type ) ; $ document = $ this -> getDomElement ( ) -> ownerDocument ; if ( 'text' === $ type || 'html' === $ type ) { $ this -> getDomElement ( ) -> nodeValue = ( string ) $ content ; } elseif ( 'xhtml' === $ type ) { if ( ! $ content instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( 'Content should be an instance of DOMElement' ) ; } Xhtml :: import ( $ content , $ this -> getDomElement ( ) ) ; } elseif ( $ this -> isXmlMimeType ( $ type ) ) { if ( ! $ content instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( 'Content should be an instance of DOMElement' ) ; } $ this -> getDomElement ( ) -> appendChild ( $ document -> importNode ( $ content , true ) ) ; } elseif ( stripos ( $ type , 'text/' ) === 0 ) { $ this -> getDomElement ( ) -> nodeValue = ( string ) $ content ; } else { $ this -> getDomElement ( ) -> nodeValue = base64_encode ( $ content ) ; } $ this -> setCachedProperty ( 'content' , $ content ) ; }
Set new content.

For "text" and "html" $type values $content should be a string.

For "xhtml" and all XML-based $type values $content should be an instance of
@{link DOMElement}.

In all other cases $content should be a binary string and it will be base64 encoded.

When $type is "xhtml" child nodes of $content will be moved to "xhtml:div" container.

@param string|\DOMElement $content
@param string             $type

@throws \InvalidArgumentException If $content type does not match given $type.

@since 1.0
Set new content .