sfFrontWebController.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. * (c) 2004-2006 Sean Kerr <sean@code-box.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * sfFrontWebController allows you to centralize your entry point in your web
  12. * application, but at the same time allow for any module and action combination
  13. * to be requested.
  14. *
  15. * @package symfony
  16. * @subpackage controller
  17. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  18. * @author Sean Kerr <sean@code-box.org>
  19. * @version SVN: $Id: sfFrontWebController.class.php 7792 2008-03-09 22:06:59Z fabien $
  20. */
  21. class sfFrontWebController extends sfWebController
  22. {
  23. /**
  24. * Dispatches a request.
  25. *
  26. * This will determine which module and action to use by request parameters specified by the user.
  27. */
  28. public function dispatch()
  29. {
  30. try
  31. {
  32. if (sfConfig::get('sf_logging_enabled'))
  33. {
  34. $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Dispatch request')));
  35. }
  36. // reinitialize filters (needed for unit and functional tests)
  37. sfFilter::$filterCalled = array();
  38. // determine our module and action
  39. $request = $this->context->getRequest();
  40. $moduleName = $request->getParameter('module');
  41. $actionName = $request->getParameter('action');
  42. if (empty($moduleName) || empty($actionName))
  43. {
  44. throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
  45. }
  46. // make the first request
  47. $this->forward($moduleName, $actionName);
  48. }
  49. catch (sfException $e)
  50. {
  51. $e->printStackTrace();
  52. }
  53. catch (Exception $e)
  54. {
  55. sfException::createFromException($e)->printStackTrace();
  56. }
  57. }
  58. }