Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. \routing.yml
  2. login:
  3. pattern: /login
  4. defaults: { _controller : MyAppBundle:Security:login }
  5.  
  6. login_check:
  7. pattern: /login_check
  8.  
  9. logout:
  10. pattern: /logout
  11.  
  12. // SecurityController.php
  13. ...
  14. class SecurityController extends Controller{
  15.  
  16. public function loginAction(){
  17. if($test_if_credentials_present){
  18. $response = $this->forward('login_check',
  19. array('_username' => $username, '_password' => $password);
  20. return $response;
  21. }
  22. }
  23. }
  24.  
  25. php app/console router:debug login_check
  26.  
  27. [router] Route "login_check"
  28. Name login_check
  29. Path /login_check
  30. Host ANY
  31. Scheme ANY
  32. Method ANY
  33. Class SymfonyComponentRoutingRoute
  34. Defaults
  35. Requirements NO CUSTOM
  36. Options compiler_class: SymfonyComponentRoutingRouteCompiler
  37. Path-Regex #^/login_check$#s
  38.  
  39. $router = $this->get('router');
  40.  
  41. $uri = $router->generate('login_check'); // /login_check
  42.  
  43. $attributes = $router->match($uri);
  44.  
  45. Array
  46. (
  47. [_controller] => AcmeFooBundleControllerLoginController::checkAction
  48. [_route] => login_check
  49. )
  50.  
  51. return $this->forward($attributes['_controller'], array(
  52. '_username' => $username,
  53. '_password' => $password
  54. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement