Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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
 * 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: sfActions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
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
   * @param sfRequest $request The current sfRequest object
30
   *
31
   * @return string    A string containing the view name associated with this action
32
   *
33
   * @throws sfInitializationException
34
   *
35
   * @see sfAction
36
   */
37
  public function execute($request)
38
  {
39
    // dispatch action
40
    $actionToRun = 'execute'.ucfirst($this->getActionName());
41
 
42
    if ($actionToRun === 'execute')
43
    {
44
      // no action given
45
      throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s". There was no action given.', $this->getModuleName()));
46
    }
47
 
48
    if (!is_callable(array($this, $actionToRun)))
49
    {
50
      // action not found
51
      throw new sfInitializationException(sprintf('sfAction initialization failed for module "%s", action "%s". You must create a "%s" method.', $this->getModuleName(), $this->getActionName(), $actionToRun));
52
    }
53
 
54
    if (sfConfig::get('sf_logging_enabled'))
55
    {
56
      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Call "%s->%s()"', get_class($this), $actionToRun))));
57
    }
58
 
59
    // run action
60
    return $this->$actionToRun($request);
61
  }
62
}