Advertisement
Guest User

Untitled

a guest
Jul 18th, 2012
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # ROUTE
  2. 'test' => array(
  3. 'type' => 'segment',
  4. 'options' => array(
  5. 'route' => '/test[/:action][/:id]',
  6. 'constraints' => array(
  7. 'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
  8. 'par' => '[0-9]+',
  9. ),
  10. 'defaults' => array(
  11. 'controller' => 'test/test',
  12. 'action' => 'index',
  13. ),
  14. ),
  15. ),
  16.  
  17. # CONTROLLER
  18. <?php
  19. namespace Something\Controller;
  20.  
  21. class TestController extends AbstractActionController
  22. {
  23. public function indexAction()
  24. {
  25. echo 'index';
  26. echo (int) $this->params()->fromRoute('id');
  27. }
  28. public function hahaAction()
  29. {
  30. echo 'haha';
  31. echo (int) $this->params()->fromRoute('id');
  32. }
  33. }
  34.  
  35. # URLS
  36. /test prints index0
  37. /test/haha prints haha0
  38. /test/haha/33 prints haha33
  39. /test/33 prints my layout + error page with "The requested controller was unable to dispatch the request."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement