Example #1
0
 /**
  * Render single Work page
  *
  * @param Work $work
  * @return array
  * @Route("/work/{slug}", name="app_work_page")
  * @Method("GET")
  * @Template()
  * @ParamConverter("work",
  *                  class="RainlikeAppBundle:Work",
  *                  options={"slug" = "slug"}
  * )
  */
 public function workAction(Work $work)
 {
     $profile = $this->get('entity')->profiles()->getBaseProfile();
     $subtitle = $work->getName();
     return ['profile' => $profile, 'work' => $work, 'subtitle' => $subtitle];
 }
Example #2
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();
         }
     }
 }