[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_app/src/controller/ -> lmbDynamicCommandController.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/core/src/lmbHandle.class.php');
  10  lmb_require('limb/web_app/src/controller/lmbAbstractController.class.php');
  11  
  12  /**

  13   * class lmbDynamicCommandController.

  14   *

  15   * @package web_app

  16   * @version $Id: lmbDynamicCommandController.class.php 5945 2007-06-06 08:31:43Z pachanga $

  17   */
  18  class lmbDynamicCommandController extends lmbAbstractController
  19  {
  20    function actionExists($action)
  21    {
  22      if($this->_findCommandPathForAction($action))
  23        return true;
  24  
  25      if($this->_findTemplateForAction($action))
  26        return true;
  27  
  28      return false;
  29    }
  30  
  31    function performAction()
  32    {
  33      $command = $this->getActionCommand();
  34      $command->perform();
  35    }
  36  
  37    function getActionCommand()
  38    {
  39      if(!$this->current_action)
  40        throw new lmbException('Current action is not defined in controller "' . $this->getName());
  41  
  42      if($command_path = $this->_findCommandPathForAction($this->current_action))
  43        return new lmbHandle($command_path);
  44  
  45      if($template_path = $this->_findTemplateForAction($this->current_action))
  46        return new lmbHandle('limb/web_app/src/command/lmbActionCommand', array($template_path));
  47  
  48      throw new lmbException('Could not find command class for action "' . $this->current_action . '" in controller "' . $this->getName());
  49    }
  50  
  51    protected function _findCommandPathForAction($action)
  52    {
  53      $path = "src/command/" . $this->getName() . "/" . lmb_camel_case($this->getName() . '_' . $action) . "Command.class.php";
  54      return lmb_resolve_include_path($path);
  55    }
  56  }
  57  
  58  ?>


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7