Exemplo n.º 1
0
 private function createCharacter($info)
 {
     $character = new Person();
     $character->setName($info['character']);
     $actor = $this->em->getRepository('AppBundle:Actor')->findByIdTrakt($info['person']['ids']['trakt']);
     if (!$actor) {
         $actor = new Actor();
         $actor->setName($info['person']['name'])->setIdTrakt($info['person']['ids']['trakt'])->setSlug($info['person']['ids']['slug'])->setBirthday(new \DateTime($info['person']['birthday']))->setBirthplace($info['person']['birthplace'])->setBiography($info['person']['biography']);
         if ($info['person']['death']) {
             $actor->setDeath(new \DateTime($info['person']['death']));
         }
         $this->insertImage($actor, $info['person']['images']);
         $this->em->persist($actor);
     } else {
         $actor = $actor[0];
     }
     $character->setActor($actor);
     $this->em->persist($character);
     return $character;
 }