aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Acme/DemoBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Acme/DemoBundle/Controller')
-rw-r--r--src/Acme/DemoBundle/Controller/DemoController.php56
-rw-r--r--src/Acme/DemoBundle/Controller/SecuredController.php70
-rw-r--r--src/Acme/DemoBundle/Controller/WelcomeController.php19
3 files changed, 0 insertions, 145 deletions
diff --git a/src/Acme/DemoBundle/Controller/DemoController.php b/src/Acme/DemoBundle/Controller/DemoController.php
deleted file mode 100644
index a99de891..00000000
--- a/src/Acme/DemoBundle/Controller/DemoController.php
+++ /dev/null
@@ -1,56 +0,0 @@
1<?php
2
3namespace Acme\DemoBundle\Controller;
4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\HttpFoundation\RedirectResponse;
7use Symfony\Component\HttpFoundation\Request;
8use Acme\DemoBundle\Form\ContactType;
9
10// these import the "@Route" and "@Template" annotations
11use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
13
14class DemoController extends Controller
15{
16 /**
17 * @Route("/", name="_demo")
18 * @Template()
19 */
20 public function indexAction()
21 {
22 return array();
23 }
24
25 /**
26 * @Route("/hello/{name}", name="_demo_hello")
27 * @Template()
28 */
29 public function helloAction($name)
30 {
31 return array('name' => $name);
32 }
33
34 /**
35 * @Route("/contact", name="_demo_contact")
36 * @Template()
37 */
38 public function contactAction(Request $request)
39 {
40 $form = $this->createForm(new ContactType());
41 $form->handleRequest($request);
42
43 if ($form->isValid()) {
44 $mailer = $this->get('mailer');
45
46 // .. setup a message and send it
47 // http://symfony.com/doc/current/cookbook/email.html
48
49 $request->getSession()->getFlashBag()->set('notice', 'Message sent!');
50
51 return new RedirectResponse($this->generateUrl('_demo'));
52 }
53
54 return array('form' => $form->createView());
55 }
56}
diff --git a/src/Acme/DemoBundle/Controller/SecuredController.php b/src/Acme/DemoBundle/Controller/SecuredController.php
deleted file mode 100644
index d1499e39..00000000
--- a/src/Acme/DemoBundle/Controller/SecuredController.php
+++ /dev/null
@@ -1,70 +0,0 @@
1<?php
2
3namespace Acme\DemoBundle\Controller;
4
5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Security\Core\SecurityContext;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
11
12/**
13 * @Route("/demo/secured")
14 */
15class SecuredController extends Controller
16{
17 /**
18 * @Route("/login", name="_demo_login")
19 * @Template()
20 */
21 public function loginAction(Request $request)
22 {
23 if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
24 $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
25 } else {
26 $error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
27 }
28
29 return array(
30 'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
31 'error' => $error,
32 );
33 }
34
35 /**
36 * @Route("/login_check", name="_demo_security_check")
37 */
38 public function securityCheckAction()
39 {
40 // The security layer will intercept this request
41 }
42
43 /**
44 * @Route("/logout", name="_demo_logout")
45 */
46 public function logoutAction()
47 {
48 // The security layer will intercept this request
49 }
50
51 /**
52 * @Route("/hello", defaults={"name"="World"}),
53 * @Route("/hello/{name}", name="_demo_secured_hello")
54 * @Template()
55 */
56 public function helloAction($name)
57 {
58 return array('name' => $name);
59 }
60
61 /**
62 * @Route("/hello/admin/{name}", name="_demo_secured_hello_admin")
63 * @Security("is_granted('ROLE_ADMIN')")
64 * @Template()
65 */
66 public function helloadminAction($name)
67 {
68 return array('name' => $name);
69 }
70}
diff --git a/src/Acme/DemoBundle/Controller/WelcomeController.php b/src/Acme/DemoBundle/Controller/WelcomeController.php
deleted file mode 100644
index 884f95bb..00000000
--- a/src/Acme/DemoBundle/Controller/WelcomeController.php
+++ /dev/null
@@ -1,19 +0,0 @@
1<?php
2
3namespace Acme\DemoBundle\Controller;
4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
7class WelcomeController extends Controller
8{
9 public function indexAction()
10 {
11 /*
12 * The action's view can be rendered using render() method
13 * or @Template annotation as demonstrated in DemoController.
14 *
15 */
16
17 return $this->render('AcmeDemoBundle:Welcome:index.html.twig');
18 }
19}