From 81190f4517646c760b50d779cfc951b08cce5ed7 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Thu, 24 May 2018 10:20:50 +0200
Subject: [PATCH] dev #75244 : fix test and refacto les yeux doc

---
 .../WebService/BibNumerique/ArteVOD/Film.php  | 34 ++++++++++++-------
 .../LesYeuxDoc/Service/Film.php               | 13 ++-----
 2 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/library/Class/WebService/BibNumerique/ArteVOD/Film.php b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
index c275823bfce..c3c22ac8097 100644
--- a/library/Class/WebService/BibNumerique/ArteVOD/Film.php
+++ b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
@@ -40,19 +40,23 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
          ->setDescription($json['description'])
          ->addPoster($json['posterUrl'])
          ->setDirectors($json['directors'])
-         ->setGenres(isset($json['genres']) ? $json['genres'] : [])
-         ->addTrailer(isset($json['trailerUrl']) ? $json('trailerUrl') : '')
          ->setExternalUri($json['url'])
-         ->addMedias(isset($json['medias']) ? $json['medias'] : [])
-         ->addThemes($json['themes'])
-         ->setYear(isset($json['productionYear']) ?
-                   $json['productionYear'] :
-                   (isset($json['publicationDate']) ?
-                          explode('-', $json['publicationDate'])[0]
-                    :''))
          ->addActors(isset($json['actors']) ?
                      $json['actors'] : [])
-         ->addDuration($json['duration']);
+         ->addDuration($json['duration'])
+         ->addMedias(isset($json['medias']) ? $json['medias'] : [])
+         ->addThemes($json['themes'])
+;
+
+    if (isset($json['genres']))
+      $this->setGenres($json['genres']);
+    if (isset($json['trailerUrl']))
+      $this->addTrailer($json['trailerUrl'] );
+    if (isset($json['productionYear']))
+      $this->setYear($json['productionYear']);
+    if (isset($json['publicationDate']))
+      $this->setYear(explode('-', $json['publicationDate'])[0]);
+
   }
 
 
@@ -92,11 +96,15 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
     return $this;
   }
 
+  protected function setTypeDoc($album) {
+    return $album->beArteVOD();
+  }
+
 
   public function fillAlbum($album) {
-    $album->beArteVOD()
-          ->setDuration($this->duration.' mn')
-          ->setTags($this->getTags());
+    $this->setTypeDoc($album)
+         ->setDuration($this->duration.' mn')
+         ->setTags($this->getTags());
 
     foreach ($this->getActors() as $actor)
       $album->addAuthor(trim($actor['familyName'] . ' ' . $actor['givenName']),
diff --git a/library/digital_resources/LesYeuxDoc/Service/Film.php b/library/digital_resources/LesYeuxDoc/Service/Film.php
index db58f3af657..61fc1015d3a 100644
--- a/library/digital_resources/LesYeuxDoc/Service/Film.php
+++ b/library/digital_resources/LesYeuxDoc/Service/Film.php
@@ -21,18 +21,9 @@
 
 
 class LesYeuxDoc_Service_Film extends Class_WebService_BibNumerique_ArteVOD_Film {
-  public function fillAlbum($album) {
-    $album->setTypeDocId(LesYeuxDoc_Config::getInstance()->getDocType());
-    $album->setDuration($this->duration.' mn')
-          ->setTags($this->getTags());
-
-    foreach ($this->getActors() as $actor)
-      $album->addAuthor(trim($actor['familyName'] . ' ' . $actor['givenName']),
-                        '005');
-    foreach ($this->_directors as $director)
-      $album->addAuthor(trim($director['familyName'] . ' ' . $director['givenName']),
-                        '300');
 
+  protected function setTypeDoc($album) {
+    $album->setTypeDocId(LesYeuxDoc_Config::getInstance()->getDocType());
     return $album;
   }
 
-- 
GitLab