1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
namespace App\Controller;
use App\Entity\Faq;
use App\Entity\Page;
use App\Entity\User;
use App\Entity\Usergroup;
use App\Form\Type\AdhererFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use Doctrine\ORM\EntityManagerInterface;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use Swagger\Annotations as SWG;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
private $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* @Route("/", name="index")
*/
// public function index(TranslatorInterface $translator)
public function index(Request $request)
{
// Exemple pour la traduction :
// $translated = $translator->trans('Symfony is great');
// $translator->transChoice(
// 'Hurry up %name%! There is one apple left.|There are %count% apples left.',
// 10,
// // no need to include %count% here; Symfony does that for you
// array('%name%' => $user->getName())
// );
return $this->render('index.html.twig', [
'news' => array(),
]);
}
/**
* @Route("/adherer", name="adherer")
*/
public function adhererAction(Request $request)
{
// @TODO : formulaire d'adhésion sans cotisation ? à valider après ?
// $adherent = new Adherent();
// $user = $this->um->createUser();
// $groupe = $this->em->getRepository(Usergroup::class)->findOneByName('Adherent');
// $user->setEnabled(true);
// $user->addGroup($groupe);
// $user->addRole('ROLE_ADHERENT');
// $adherent->setEcompte('0');
// $user->setAdherent($adherent);
// $adherent->setUser($user);
// if (count($adherent->getUser()->getCotisations()) <= 0) {
// $cotisation = new Cotisation();
// $cotisation->setDebut(new \DateTime());
// $cotisation->setFin(new \DateTime('+ 1 year'));
// $adherent->getUser()->addCotisation($cotisation);
// }
// if ($adherent->getGeoloc() == null) {
// $adherent->setGeoloc(new Geoloc());
// }
$form = $this->createForm(AdhererFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// $this->em->persist($adherent);
// $this->em->flush();
// $this->addFlash(
// 'success',
// 'Adhésion bien pris en compte, vous recevrez un email très bientôt !'
// );
}
return $this->render('adherent/adherer.html.twig', array(
'user' => $this->getUser(),
'form' => $form->createView()
));
}
/**
* @Route("/group/choice/{id}", name="group_choice")
*/
public function groupChoiceAction(Usergroup $group, Request $request)
{
$request->getSession()->remove('_choixGroup');
// On enregistre le rôle choisit en session
$request->getSession()->set('_groupId', $group);
// @TODO : On redirige sur l'index (ou en fonction du rôle?)
return $this->redirectToRoute('index');
}
/**
* @Route("/page/{slug}", name="show_page")
*/
public function pageAction(Page $page)
{
$template = 'page.html.twig';
if (!empty($page->getTemplate()) && $this->get('templating')->exists($page->getTemplate())) {
$template = $page->getTemplate();
}
return $this->render($template, array(
'page' => $page
));
}
/**
* @Route("/faq", name="faq")
*/
public function faqAction()
{
return $this->render('faq/liste.html.twig', array(
'faqs' => $this->em->getRepository(Faq::class)->findBy(array('enabled' => true), array('createdAt' => 'DESC'))
));
}
/**
* @Route("/faq/{slug}", name="show_faq")
*/
public function showFaqAction(Faq $faq)
{
return $this->render('faq/show.html.twig', array(
'faq' => $faq
));
}
/**
* @Route("/contact", name="contact")
*/
public function contactAction()
{
return $this->render('contact.html.twig');
}
}