public function createCity($nom, $reference, $postal) { $city = new City(); $city->setNom($nom); $city->setDepartement($reference); $city->setPostal($postal); return $city; }
public function createCity($nom, $reference, $postal) { $city = new City(); $city->setNom($nom); $city->setDepartement($reference); $city->setPostal($postal); if ($nom == 'Rians') { $this->addReference('ville-rians', $city); } return $city; }
public function followCityAction(Request $request, City $city) { if ($request->isXmlHttpRequest()) { $response = new JsonResponse(); $em = $this->getDoctrine()->getEntityManager(); $user = $this->getUser(); if (!is_object($user) || !$user instanceof User) { throw new AccessDeniedException('This user does not have access to this section.'); } $followedCity = $user->getFollowedcity(); $toArray = array(); foreach ($followedCity as $r) { $toArray[] = $r->getId(); } if (in_array($city->getId(), $toArray)) { $user->removeFollowedcity($city); $response->setData(array('username' => $city->getNom(), 'subject' => "Vous n'êtes plus abonné à ")); } else { $user->addFollowedcity($city); $response->setData(array('username' => $city->getNom(), 'subject' => 'Vous êtes abonné à ')); $this->get('event_dispatcher')->dispatch(SkuagEvents::ON_FOLLOW_CITY, new FollowCityEvent($city, $user)); } $em->flush(); return $response; } return $this->errorMethodRequest(); }
public function showByCityAction(Request $request, City $city) { // Le manager des annonces $advertManager = $this->getAdvertManager(); $choices = null; $user = $this->getUser(); $userFollow = false; // Controle si la région demandé existe $page_title = $city->getNom(); if ($request->isMethod('post')) { $choices = $advertManager->recordChoiceFilter(); } else { $advertManager->removeChoiceSession(); } $advertListToPaginate = $advertManager->getAdvertByCity($city, $choices); $advertList = $this->get('knp_paginator')->paginate($advertListToPaginate, $request->query->getInt('page', 1), 10); $breadcrumb = array(array($city->getDepartement()->getRegion()->getNom(), $this->generateUrl('snoozit_platform_show_by_region', array('slug' => $city->getDepartement()->getRegion()->getSlug()))), array($city->getDepartement()->getNom(), $this->generateUrl('snoozit_platform_show_by_departement', array('slug' => $city->getDepartement()->getSlug()))), array($city->getNom(), '#', true)); if (is_object($user) || $user instanceof User) { $userFollow = $this->checkIfUserFollow($city); } $requestRubriqueId = $city->getId(); return $this->getGlobalAdvertTemplating($advertList, $breadcrumb, $choices, $page_title, null, $userFollow, $requestRubriqueId); }