Ejemplo n.º 1
0
 public function load(ObjectManager $manager)
 {
     foreach ($this->works as $work) {
         $entity = new Work();
         $entity->setName($work['name']);
         $entity->setType($work['type']);
         $entity->setUrl($work['url']);
         $entity->setImage($work['image']);
         $entity->setPreview($work['preview']);
         if (array_key_exists('description', $work)) {
             $entity->setDescription($work['description']);
         }
         $entity->setContribution($work['contribution']);
         $entity->setTechnology($work['technology']);
         $entity->setEnabled(true);
         $entity->setProfile($manager->merge($this->getReference($work['profile'])));
         $manager->persist($entity);
         $this->addReference('work-' . strtolower($work['slug']), $entity);
         $manager->flush();
         foreach ($work['translations'] as $locale => $translation) {
             $entity->setTranslatableLocale($locale);
             $entity->setPreview($translation['preview']);
             if (array_key_exists('description', $translation)) {
                 $entity->setDescription($translation['description']);
             }
             $entity->setContribution($translation['contribution']);
             $manager->persist($entity);
             $manager->flush();
         }
     }
 }