[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/components/ -> WactClassPath.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  
  10  /**

  11   * class WactClassPath.

  12   *

  13   * @package wact

  14   * @version $Id$

  15   */
  16  class WactClassPath
  17  {
  18    protected $class_name;
  19    protected $include_path;
  20  
  21    function __construct($raw_path_or_class_name, $include_path = '')
  22    {
  23      $raw_path_or_class_name = $this->_parseConstants($raw_path_or_class_name);
  24  
  25      if($include_path)
  26        $this->include_path = $include_path;
  27      elseif(WactTemplate :: isFileReadable($raw_path_or_class_name . '.class.php'))
  28        $this->include_path = $raw_path_or_class_name . '.class.php';
  29  
  30      $this->class_name = end(explode('/', $raw_path_or_class_name));
  31    }
  32  
  33    function createObject($args = array())
  34    {
  35      if(!class_exists($this->class_name) && $this->include_path)
  36        require_once($this->include_path);
  37  
  38      $refl = new ReflectionClass($this->class_name);
  39      return call_user_func_array(array($refl, 'newInstance'),$args);
  40    }
  41  
  42    protected function _parseConstants($value)
  43    {
  44      return preg_replace('~\{([^\}]+)\}~e', "constant('\\1')", $value);
  45    }
  46  }
  47  
  48  ?>


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