Ejemplo n.º 1
0
 /**
  * Creates an ATOM ENTRY instance with specified simpleXML object
  *
  * @param \SimpleXMLElement $entryXml xml element of ATOM ENTRY
  *
  * @return none
  */
 public function fromXml($entryXml)
 {
     Validate::notNull($entryXml, 'entryXml');
     Validate::isA($entryXml, '\\SimpleXMLElement', 'entryXml');
     $this->attributes = (array) $entryXml->attributes();
     $entryArray = (array) $entryXml;
     if (array_key_exists(Resources::AUTHOR, $entryArray)) {
         $this->author = $this->processAuthorNode($entryArray);
     }
     if (array_key_exists(Resources::CATEGORY, $entryArray)) {
         $this->category = $this->processCategoryNode($entryArray);
     }
     if (array_key_exists('content', $entryArray)) {
         $content = new Content();
         $content->fromXml($entryArray['content']);
         $this->content = $content;
     }
     if (array_key_exists(Resources::CONTRIBUTOR, $entryArray)) {
         $this->contributor = $this->processContributorNode($entryArray);
     }
     if (array_key_exists('id', $entryArray)) {
         $this->id = (string) $entryArray['id'];
     }
     if (array_key_exists(Resources::LINK, $entryArray)) {
         $this->link = $this->processLinkNode($entryArray);
     }
     if (array_key_exists('published', $entryArray)) {
         $this->published = $entryArray['published'];
     }
     if (array_key_exists('rights', $entryArray)) {
         $this->rights = $entryArray['rights'];
     }
     if (array_key_exists('source', $entryArray)) {
         $source = new Source();
         $source->parseXml($entryArray['source']->asXML());
         $this->source = $source;
     }
     if (array_key_exists('title', $entryArray)) {
         $this->title = $entryArray['title'];
     }
     if (array_key_exists('updated', $entryArray)) {
         $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $entryArray['updated']);
     }
 }