Advertisement
Guest User

HoiWorldController

a guest
Sep 7th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <?php
  2. namespace Acme\TestBundle\Controller;
  3.  
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8.  
  9. class HoiWorldController extends Controller {
  10.  
  11.     /**
  12.     * @Route("/hoi/{msg}", name="acme_hoi")
  13.     */
  14.     public function greatingAction($msg)
  15.     {
  16.    
  17.         $html = $this->container
  18.             ->get('templating')
  19.             ->render(
  20.                 'AcmeTestBundle:Hoi:hoi.html.twig',
  21.                 array('msg' => $msg)
  22.             );
  23.        
  24.         return new Response($html);
  25.     }
  26.    
  27.     /**
  28.      * @Route("/hoi2/{msg}", name="acme_hoi2")
  29.      */
  30.     public function greating2Action($msg)
  31.     {
  32.    
  33.         return $this->render('AcmeTestBundle:Hoi:hoi.html.twig', array('msg' => $msg) );
  34.     }
  35.  
  36.     /**
  37.      * Hanya redirect / Just redirect to acme_hoi2
  38.      * @Route("/hoi3/{msg}", name="acme_hoi3")
  39.      */
  40.     public function greating3Action($msg)
  41.     {
  42.         return $this->redirectToRoute('acme_hoi2', ['msg' => $msg ] ); // > 2.6 only
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement