Example #1
0
 /**
  * Create an Article object from XML
  *
  * @param SimpleXMLElement $xml simpleXML element containing a single article XML
  *
  * @static
  *
  * @return phpOpenNOS\Model\Article
  */
 public static function fromXML(\SimpleXMLElement $xml)
 {
     $article = new Article();
     $article->setId((int) $xml->id);
     $article->setTitle((string) $xml->title);
     $article->setDescription((string) $xml->description);
     $article->setPublished((string) $xml->published);
     $article->setLastUpdate((string) $xml->last_update);
     $article->setThumbnailXS((string) $xml->thumbnail_xs);
     $article->setThumbnailS((string) $xml->thumbnail_s);
     $article->setThumbnailM((string) $xml->thumbnail_m);
     $article->setLink((string) $xml->link);
     $keywords = array();
     foreach ($xml->keywords->keyword as $keyword) {
         $keywords[] = (string) $keyword;
     }
     $article->setKeywords($keywords);
     return $article;
 }
Example #2
0
 protected function buildDomainObject($row)
 {
     $article = new Article();
     $article->setCode($row['CODEART']);
     $article->setLibelle($row['LIBELLEART']);
     $article->setTaille($row['TAILLE']);
     $article->setPrix($row['Prix']);
     $article->setDescription($row['DESCRIPTION']);
     if (array_key_exists('CodeType', $row)) {
         // Trouve et définit le type associé
         $typearticleId = $row['CodeType'];
         $typearticle = $this->typearticleDAO->find($typearticleId);
         $article->setTypearticle($typearticle);
     }
     if (array_key_exists('CODECOULEUR', $row)) {
         // Trouve et définit le type associé
         $coueleurarticleID = $row['CODECOULEUR'];
         $couleurarticle = $this->couleurarticleDAO->find($coueleurarticleID);
         $article->setCouleurarticle($couleurarticle);
     }
     return $article;
 }