[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/components/perform/ -> WactPerformComponent.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  require_once('limb/wact/src/components/WactClassPath.class.php');
  10  
  11  /**

  12   * class WactPerformComponent.

  13   *

  14   * @package wact

  15   * @version $Id$

  16   */
  17  class WactPerformComponent extends WactRuntimeComponent
  18  {
  19    protected $command;
  20    protected $method_name = 'perform';
  21    protected $params = array();
  22    protected $include_path;
  23  
  24    function setCommand($command)
  25    {
  26      $this->command = $command;
  27    }
  28  
  29    function setIncludePath($path)
  30    {
  31      $this->include_path = $path;
  32    }
  33  
  34    function setMethod($method)
  35    {
  36      $this->method_name = $method;
  37    }
  38  
  39    function addParam($value)
  40    {
  41      $this->params[] = $value;
  42    }
  43  
  44    function process($template)
  45    {
  46      $command = $this->_createCommand($template);
  47  
  48      if(!is_a($command, 'WactTemplateCommand'))
  49        throw new WactException($this->command. '" must inherite from WactTemplateCommand class');
  50  
  51      $method = WactTemplate :: toStudlyCaps('do_' . $this->method_name, false);
  52      if(!method_exists($command, $method))
  53        throw new WactException('Template command "' .$this->command. '" does not support method: '. $method);
  54  
  55      return call_user_func_array(array($command, $method), $this->params);
  56    }
  57  
  58    protected function _createCommand($template)
  59    {
  60      $class_path = new WactClassPath($this->command, $this->include_path);
  61      return $class_path->createObject(array($template, $this->parent));
  62    }
  63  }
  64  ?>


Generated: Tue Oct 14 04:47:40 2008 Cross-referenced by PHPXref 0.7