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