예제 #1
0
 public function getAdvertListToProposeForPanier(Advert $advert, $max = 3)
 {
     $qb = $this->getByLocalisationQueryBuilder();
     $qb->having('a.id != :advertId')->where('a.slug = :advertSlug')->orWhere('a.description = :advertDescription')->orWhere('b.id = :advertCategory')->orWhere('c.id = :advertCity')->addOrderBy('a.created', 'desc')->setMaxResults($max)->setParameters(array('advertId' => $advert->getId(), 'advertSlug' => $advert->getSlug(), 'advertCategory' => $advert->getCategory(), 'advertDescription' => $advert->getDescription(), 'advertCity' => $advert->getCity()));
     $result = $qb->getQuery()->getArrayResult();
     return $result;
 }
예제 #2
0
 public function interestedByAction(Advert $advert)
 {
     if ($advert->getGuest()) {
         return $this->redirect($this->generateUrl('snoozit_platform_error_page', array('codeErreur' => 1)));
     }
     if (!is_object($this->getUser()) || !$this->getUser() instanceof UserInterface) {
         throw new AccessDeniedException('Vous devez etre identifié pour pouvoir acceder à cette zone.');
     }
     $advertManager = $this->getAdvertManager();
     $response = $this->redirect($this->generateUrl('snoozit_platform_add_in_panier', array('id' => $advert->getId())));
     $session = $this->get('session');
     // ProcessInterest va controller si oui ou non
     // l'interet existe en BDD et ajuste le résultat
     if ($advertManager->processInterest($advert)) {
         // Si l'interet est supprimé et que donc la session "_interestRemove" existe
         if ($session->has('_interestRemove')) {
             // La session "_interestRemove" correspond à notre annonce
             if ($session->get('_interestRemove') == $advert->getId()) {
                 return $this->redirect($this->generateUrl('snoozit_platform_remove_in_panier', array('id' => $advert->getId())));
             }
             // Ca ne correspond pas a notre annonce
             return $this->redirect($this->generateUrl('snoozit_dashboard_homepage'));
         }
         $session->set('add_in_panier', true);
         return $response;
     }
     $session->set('add_in_panier', true);
     return $response;
 }
 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);
 }
예제 #4
0
 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));
 }
예제 #5
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));
 }