|
|
@@ -5,8 +5,10 @@ namespace Muzich\IndexBundle\Controller;
|
|
5
|
5
|
use Muzich\CoreBundle\lib\Controller;
|
|
6
|
6
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
|
7
|
7
|
use Symfony\Component\Security\Core\SecurityContext;
|
|
8
|
|
-
|
|
9
|
|
-//use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
|
8
|
+use Symfony\Component\Validator\Constraints\Email;
|
|
|
9
|
+use Symfony\Component\Validator\Constraints\Collection;
|
|
|
10
|
+use Muzich\CoreBundle\Entity\Presubscription;
|
|
|
11
|
+use Symfony\Component\HttpFoundation\Request;
|
|
10
|
12
|
|
|
11
|
13
|
class IndexController extends Controller
|
|
12
|
14
|
{
|
|
|
@@ -28,10 +30,19 @@ class IndexController extends Controller
|
|
28
|
30
|
$form = $this->container->get('fos_user.registration.form');
|
|
29
|
31
|
|
|
30
|
32
|
return array_merge($vars, array(
|
|
31
|
|
- 'form' => $form->createView()
|
|
|
33
|
+ 'form' => $form->createView(),
|
|
|
34
|
+ 'presubscription_form' => $this->getPreSubscriptionForm()->createView()
|
|
32
|
35
|
));
|
|
33
|
36
|
}
|
|
34
|
37
|
|
|
|
38
|
+ protected function getPreSubscriptionForm()
|
|
|
39
|
+ {
|
|
|
40
|
+ return $this->createFormBuilder(new Presubscription())
|
|
|
41
|
+ ->add('email', 'email')
|
|
|
42
|
+ ->getForm()
|
|
|
43
|
+ ;
|
|
|
44
|
+ }
|
|
|
45
|
+
|
|
35
|
46
|
/**
|
|
36
|
47
|
* Gestion du formulaire d'identification sur la page d'index.
|
|
37
|
48
|
*
|
|
|
@@ -68,4 +79,26 @@ class IndexController extends Controller
|
|
68
|
79
|
);
|
|
69
|
80
|
}
|
|
70
|
81
|
|
|
|
82
|
+ public function presubscriptionAction(Request $request)
|
|
|
83
|
+ {
|
|
|
84
|
+ $form = $this->getPreSubscriptionForm();
|
|
|
85
|
+ $form->bindRequest($request);
|
|
|
86
|
+ if ($form->isValid())
|
|
|
87
|
+ {
|
|
|
88
|
+ $this->persist($form->getData());
|
|
|
89
|
+ $this->flush();
|
|
|
90
|
+ $this->setFlash('success', 'presubscription.success');
|
|
|
91
|
+ return $this->redirect($this->generateUrl('index'));
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ $this->setFlash('error', 'presubscription.error');
|
|
|
95
|
+ return $this->render('MuzichIndexBundle:Index:index.html.twig', array(
|
|
|
96
|
+ 'form' => $this->container->get('fos_user.registration.form')->createView(),
|
|
|
97
|
+ 'presubscription_form' => $form->createView(),
|
|
|
98
|
+ 'last_username' => '',
|
|
|
99
|
+ 'error' => '',
|
|
|
100
|
+ 'registration_errors_pers' => array()
|
|
|
101
|
+ ));
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
71
|
104
|
}
|