public function editAdvertAction(Advert $advert)
 {
     if ($advert->getUser() != $this->getUser()) {
         throw new AccessDeniedException("Vous n'avez rien à faire ici, ce n'est pas votre annonce - Bon message à revoir, je sais");
     }
     // Si l'annonce est déja vendu elle devient non modifiable.
     if ($advert->getSold()) {
         return $this->forward('SnoozitPlatformBundle:DashBoard:editAdvertAlreadySold', array('advert' => $advert));
     }
     $advertHandler = $this->get('sz_advert_handler');
     // Génération du breadcrumb
     $breadcrumb = array(array('Dashboard', $this->generateUrl('snoozit_dashboard_homepage')), array('Editer une annonce', $this->generateUrl('snoozit_dashboard_edit_advert', array('advert' => $advert->getId()))), array($advert->getTitle(), '#', true));
     if ($advertHandler->process()) {
         return $this->redirect($this->generateUrl('snoozit_show_advert', array('slug' => $advert->getSlug(), 'id' => $advert->getId())));
     }
     return $this->render('SnoozitPlatformBundle:DashBoard/EditAdvert:editAdvert.html.twig', array('form' => $advertHandler->createView(), 'breadcrumb' => $breadcrumb, 'advert' => $advert));
 }
 public function advertNotification(Advert $entity)
 {
     $message = new \Swift_Message("Votre annonce sera bientôt en ligne!", $this->getTemplating()->render('SnoozitPlatformBundle:Mail/DoctrineListener/Persist:AdvertMail.html.twig', array('slug' => $entity->getSlug(), 'id' => $entity->getId(), 'title' => $entity->getTitle(), 'ownername' => $this->getUsername($entity))), 'text/html');
     $message->addTo('*****@*****.**')->addFrom('*****@*****.**');
     $this->mailer->send($message);
 }
示例#3
0
 public function editAdvertErrorUserAction(Advert $advert)
 {
     // Génération du breadcrumb
     $breadcrumb = array(array('Erreur d\'édition', $this->generateUrl('snoozit_show_advert', array('id' => $advert->getId(), 'slug' => $advert->getSlug()))), array($advert->getTitle(), '#', true));
     return $this->render('SnoozitPlatformBundle:Advert/Edit/SecurityAccess:editAdvertErrorUser.html.twig', array('advert' => $advert, 'breadcrumb' => $breadcrumb));
 }