3 namespace Acme\DemoBundle\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
6 use Symfony\Component\HttpFoundation\RedirectResponse
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use Acme\DemoBundle\Form\ContactType
;
10 // these import the "@Route" and "@Template" annotations
11 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
12 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template
;
14 class DemoController
extends Controller
17 * @Route("/", name="_demo")
20 public function indexAction()
26 * @Route("/hello/{name}", name="_demo_hello")
29 public function helloAction($name)
31 return array('name' => $name);
35 * @Route("/contact", name="_demo_contact")
38 public function contactAction(Request
$request)
40 $form = $this->createForm(new ContactType());
41 $form->handleRequest($request);
43 if ($form->isValid()) {
44 $mailer = $this->get('mailer');
46 // .. setup a message and send it
47 // http://symfony.com/doc/current/cookbook/email.html
49 $request->getSession()->getFlashBag()->set('notice', 'Message sent!');
51 return new RedirectResponse($this->generateUrl('_demo'));
54 return array('form' => $form->createView());