Пример #1
0
 protected function updateBaseTranslation(Route $route)
 {
     $route->setTranslatableLocale($this->getRequest()->getLocale());
     foreach ($route->getTranslations() as $translation) {
         /** @var RouteTranslation $translation */
         $translation->updateParentFields();
     }
 }
Пример #2
0
 /**
  * @ORM\PrePersist
  */
 public function updateParentFields()
 {
     if ($this->object->getLocale() == $this->locale) {
         $method = 'set' . ucfirst($this->field);
         if (method_exists($this->object, $method)) {
             $this->object->{$method}($this->getContent());
         }
     }
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $torres_del_paine = new Route();
     $torres_del_paine->setTitle('Ruta nautica a Torres del Paine')->setProgram($this->load_file('route_program_torres_del_paine_en'))->setAdditional($this->load_file('route_additional_torres_del_paine_en'))->setIframeCode('<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
     src="https://maps.google.com/maps/ms?msa=0&amp;msid=207804041996684053581.0004d13a53f6b3c09e4d5&amp;hl=en&amp;ie=UTF8&amp;t=h&amp;ll=-51.179447,-72.378341&amp;spn=0.528581,1.307373&amp;output=embed"></iframe>')->setTranslatableLocale('en')->setAccommodation($this->getReference('a-estancia-perales'))->addTranslation(new Translation('en', 'title', 'Ruta nautica a Torres del Paine'))->addTranslation(new Translation('en', 'program', $this->load_file('route_program_torres_del_paine_en')))->addTranslation(new Translation('en', 'additional', $this->load_file('route_additional_torres_del_paine_en')))->addTranslation(new Translation('es', 'title', 'Ruta nautica a Torres del Paine'))->addTranslation(new Translation('es', 'program', $this->load_file('route_program_torres_del_paine_es')))->addTranslation(new Translation('es', 'additional', $this->load_file('route_additional_torres_del_paine_es')));
     $manager->persist($torres_del_paine);
     for ($i = 1; $i <= 4; $i++) {
         $image = new \Site\BaseBundle\Entity\RouteImage();
         $image->setFilename("torres_del_paine{$i}.jpg");
         $image->setRoute($torres_del_paine);
         $manager->persist($image);
     }
     $manager->flush();
 }
Пример #4
0
 /**
  * @Route("/book/route/{slug}", name="book.route")
  * @Template("SiteBaseBundle:Contact:booking.html.twig")
  * @param AccommodationRoute $route
  * @param Request            $request
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function bookRouteAction(AccommodationRoute $route, Request $request)
 {
     $model = new RouteContactModel();
     $form = $this->createForm(new RouteContactType(), $model);
     if ($model = $this->process_form($form, $request)) {
         $message = new \Swift_Message('21may - Booking - Route - ' . $route->getTitle(), $this->renderView('SiteBaseBundle:Contact:booking_route.html.twig', compact('model', 'route')), 'text/html');
         $message->setFrom($this->container->getParameter('site.email.from'));
         $message->setTo($this->container->getParameter('site.email.to'));
         if ($model->getEmail()) {
             $message->setReplyTo($model->getEmail(), $model->getName());
         }
         $this->get('mailer')->send($message);
         $this->get('session')->getFlashBag()->add('contact-success', 'Your form was sent successfully');
         return $this->redirect($this->generateUrl('book.route', array('slug' => $route->getSlug())));
     }
     return array('form' => $form->createView(), 'object' => $route);
 }
Пример #5
0
 /**
  * @Method("POST")
  */
 public function orderImagesAction(Route $route)
 {
     $order = $this->getRequest()->get('images', array());
     $images = $route->getImages();
     $em = $this->getDoctrine()->getManager();
     $i = 1;
     foreach ($order as $id) {
         foreach ($images as $image) {
             /** @var AccommodationImage $image */
             if ($image->getId() == $id) {
                 $image->setStackOrder($i++) && $em->persist($image);
             }
         }
     }
     $em->flush();
     return new Response('ok');
 }