/** * Retrieves a DOMElement which corresponds to this element and all * child properties. This is used to build an entry back into a DOM * and eventually XML text for sending to the server upon updates, or * for application storage/persistence. * * @param DOMDocument $doc The DOMDocument used to construct DOMElements * @return DOMElement The DOMElement representing this element and all * child properties. */ public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) { $element = parent::getDOM($doc, $majorVersion, $minorVersion); if ($this->_rating != null) { $element->appendChild($this->_rating->getDOM($element->ownerDocument)); } if ($this->_statistics != null) { $element->appendChild($this->_statistics->getDOM($element->ownerDocument)); } if ($this->_comments != null) { $element->appendChild($this->_comments->getDOM($element->ownerDocument)); } return $element; }
public function testExtensionAttributes() { $extensionAttributes = $this->comments->extensionAttributes; $extensionAttributes['foo1'] = array('name' => 'foo1', 'value' => 'bar'); $extensionAttributes['foo2'] = array('name' => 'foo2', 'value' => 'rab'); $this->comments->extensionAttributes = $extensionAttributes; $this->assertEquals('bar', $this->comments->extensionAttributes['foo1']['value']); $this->assertEquals('rab', $this->comments->extensionAttributes['foo2']['value']); $commentsXml = $this->comments->saveXML(); $newComments = new Extension\Comments(); $newComments->transferFromXML($commentsXml); $this->assertEquals('bar', $newComments->extensionAttributes['foo1']['value']); $this->assertEquals('rab', $newComments->extensionAttributes['foo2']['value']); }
/** * Creates individual Entry objects of the appropriate type and * stores them in the $_entry array based upon DOM data. * * @param DOMNode $child The DOMNode to process */ protected function takeChildFromDOM($child) { $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; switch ($absoluteNodeName) { case $this->lookupNamespace('yt') . ':' . 'statistics': $statistics = new Extension\Statistics(); $statistics->transferFromDOM($child); $this->_statistics = $statistics; break; case $this->lookupNamespace('yt') . ':' . 'racy': $racy = new GDataExtension\Racy(); $racy->transferFromDOM($child); $this->_racy = $racy; break; case $this->lookupNamespace('yt') . ':' . 'recorded': $recorded = new Extension\Recorded(); $recorded->transferFromDOM($child); $this->_recorded = $recorded; break; case $this->lookupNamespace('yt') . ':' . 'location': $location = new Extension\Location(); $location->transferFromDOM($child); $this->_location = $location; break; case $this->lookupNamespace('gd') . ':' . 'rating': $rating = new GDataExtension\Rating(); $rating->transferFromDOM($child); $this->_rating = $rating; break; case $this->lookupNamespace('gd') . ':' . 'comments': $comments = new GDataExtension\Comments(); $comments->transferFromDOM($child); $this->_comments = $comments; break; case $this->lookupNamespace('yt') . ':' . 'noembed': $noEmbed = new Extension\NoEmbed(); $noEmbed->transferFromDOM($child); $this->_noEmbed = $noEmbed; break; case $this->lookupNamespace('gd') . ':' . 'feedLink': $feedLink = new GDataExtension\FeedLink(); $feedLink->transferFromDOM($child); $this->_feedLink[] = $feedLink; break; case $this->lookupNamespace('georss') . ':' . 'where': $where = new \Zend\GData\Geo\Extension\GeoRssWhere(); $where->transferFromDOM($child); $this->_where = $where; break; case $this->lookupNamespace('atom') . ':' . 'link': $link = new Extension\Link(); $link->transferFromDOM($child); $this->_link[] = $link; break; case $this->lookupNamespace('app') . ':' . 'control': $control = new Extension\Control(); $control->transferFromDOM($child); $this->_control = $control; break; default: parent::takeChildFromDOM($child); break; } }