Exemplo n.º 1
0
 /**
  * @param Item $item
  * @param array $body
  *
  * @return Item
  */
 public function setStudio(Item $item, $body)
 {
     $repository = $this->doctrine->getRepository('AnimeDbCatalogBundle:Studio');
     $rename = ['Arms' => 'Arms Corporation', 'Mushi Productions' => 'Mushi Production', 'Film Roman, Inc.' => 'Film Roman', 'Tezuka Production' => 'Tezuka Productions', 'CoMix Wave' => 'CoMix Wave Inc.'];
     foreach ($body['studios'] as $studio) {
         $name = isset($rename[$studio['name']]) ? $rename[$studio['name']] : $studio['name'];
         $name = $studio['name'] != $studio['filtered_name'] ? [$name, $studio['filtered_name']] : $name;
         $studio = $repository->findOneBy(['name' => $name]);
         if ($studio instanceof Studio) {
             $item->setStudio($studio);
             break;
         }
     }
     return $item;
 }
Exemplo n.º 2
0
 /**
  * Fill item
  *
  * @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
  * @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $new_item
  * @param string $field
  *
  * @return \AnimeDb\Bundle\CatalogBundle\Entity\Item
  */
 protected function fillItem(Item $item, Item $new_item, $field)
 {
     switch ($field) {
         case self::FIELD_COUNTRY:
             $item->setCountry($new_item->getCountry());
             break;
         case self::FIELD_DATE_END:
             $item->setDateEnd($new_item->getDateEnd());
             break;
         case self::FIELD_DATE_PREMIERE:
             $item->setDatePremiere($new_item->getDatePremiere());
             break;
         case self::FIELD_DURATION:
             $item->setDuration($new_item->getDuration());
             break;
         case self::FIELD_EPISODES:
             $item->setEpisodes($new_item->getEpisodes());
             break;
         case self::FIELD_EPISODES_NUMBER:
             $item->setEpisodesNumber($new_item->getEpisodesNumber());
             break;
         case self::FIELD_FILE_INFO:
             $item->setFileInfo($new_item->getFileInfo());
             break;
         case self::FIELD_GENRES:
             /* @var $new_genre \AnimeDb\Bundle\CatalogBundle\Entity\Genre */
             foreach ($new_item->getGenres() as $new_genre) {
                 $item->addGenre($new_genre);
             }
             break;
         case self::FIELD_NAMES:
             // set main name in top of names list
             $new_names = $new_item->getNames()->toArray();
             array_unshift($new_names, (new Name())->setName($new_item->getName()));
             foreach ($new_names as $new_name) {
                 $item->addName($new_name);
             }
             break;
         case self::FIELD_SOURCES:
             foreach ($new_item->getSources() as $new_source) {
                 $item->addSource($new_source);
             }
             break;
         case self::FIELD_STUDIO:
             $item->setStudio($new_item->getStudio());
             break;
         case self::FIELD_SUMMARY:
             $item->setSummary($new_item->getSummary());
             break;
     }
     return $item;
 }