Development

/branches/1.0/lib/action/sfActions.class.php

You must first sign up to be able to contribute.

root/branches/1.0/lib/action/sfActions.class.php

Revision 19911, 1.9 kB (checked in by FabianLange, 5 years ago)

[1.0, 1.1, 1.2, 1.3] added check in sfActions that prefents infinite recursion in the execute method when the action name is empty (fixes #6710)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
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  * sfActions executes all the logic for the current request.
14  *
15  * @package    symfony
16  * @subpackage action
17  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
18  * @author     Sean Kerr <sean@code-box.org>
19  * @version    SVN: $Id$
20  */
21 abstract class sfActions extends sfAction
22 {
23   /**
24    * Dispatches to the action defined by the 'action' parameter of the sfRequest object.
25    *
26    * This method try to execute the executeXXX() method of the current object where XXX is the
27    * defined action name.
28    *
29    * @return string A string containing the view name associated with this action
30    *
31    * @throws sfInitializationException
32    *
33    * @see sfAction
34    */
35   public function execute()
36   {
37     // dispatch action
38     $actionToRun = 'execute'.ucfirst($this->getActionName());
39
40     if ($actionToRun === 'execute')
41     {
42       // no action given
43       $error = 'sfAction initialization failed for module "%s". There was no action given.';
44       $error = sprintf($error, $this->getModuleName());
45       throw new sfInitializationException($error);
46     }
47
48     if (!is_callable(array($this, $actionToRun)))
49     {
50       // action not found
51       $error = 'sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.';
52       $error = sprintf($error, $this->getModuleName(), $this->getActionName(), $actionToRun);
53       throw new sfInitializationException($error);
54     }
55
56     if (sfConfig::get('sf_logging_enabled'))
57     {
58       $this->getContext()->getLogger()->info('{sfAction} call "'.get_class($this).'->'.$actionToRun.'()'.'"');
59     }
60
61     // run action
62     $ret = $this->$actionToRun();
63
64     return $ret;
65   }
66 }
67
Note: See TracBrowser for help on using the browser.