/** * 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 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->_login !== null) { $element->appendChild($this->_login->getDOM($element->ownerDocument)); } if ($this->_nickname !== null) { $element->appendChild($this->_nickname->getDOM($element->ownerDocument)); } return $element; }
public function testExtensionAttributes() { $extensionAttributes = $this->nickname->extensionAttributes; $extensionAttributes['foo1'] = array('name' => 'foo1', 'value' => 'bar'); $extensionAttributes['foo2'] = array('name' => 'foo2', 'value' => 'rab'); $this->nickname->extensionAttributes = $extensionAttributes; $this->assertEquals('bar', $this->nickname->extensionAttributes['foo1']['value']); $this->assertEquals('rab', $this->nickname->extensionAttributes['foo2']['value']); $nicknameXml = $this->nickname->saveXML(); $newNickname = new Extension\Nickname(); $newNickname->transferFromXML($nicknameXml); $this->assertEquals('bar', $newNickname->extensionAttributes['foo1']['value']); $this->assertEquals('rab', $newNickname->extensionAttributes['foo2']['value']); }
/** * Creates individual Entry objects of the appropriate type and * stores them as members of this entry 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('apps') . ':' . 'login': $login = new Extension\Login(); $login->transferFromDOM($child); $this->_login = $login; break; case $this->lookupNamespace('apps') . ':' . 'nickname': $nickname = new Extension\Nickname(); $nickname->transferFromDOM($child); $this->_nickname = $nickname; break; default: parent::takeChildFromDOM($child); break; } }