예제 #1
0
 /**
  * Instantiate a new class using the arguments array for initiation
  *
  * @param string $className
  * @param array $arguments Instanciation arguments
  * @return className
  */
 public function createClass($className, array $arguments = array())
 {
     $object = parent::createClass($className, $arguments);
     if ($object instanceof \MUtil_Registry_TargetInterface) {
         if ($this->_source instanceof \MUtil_Registry_SourceInterface) {
             $this->_source->applySource($object);
         } elseif (self::$verbose) {
             \MUtil_Echo::r("Loading target class {$className}, but source not set.");
         }
     }
     return $object;
 }
 /**
  * Create or loads the class. When only loading, this function returns a StaticCall object that
  * can be invoked lazely.
  *
  * @see \MUtil_Lazy_StaticCall
  * @see \MUtil_Registry_TargetInterface
  *
  * @param string $name The class name, minus the part in $this->_dirs.
  * @param boolean $create Create the object, or only when an \MUtil_Registry_TargetInterface instance.
  * @param array $arguments Class initialization arguments.
  * @return mixed A class instance or a \MUtil_Lazy_StaticCall object
  */
 protected function _loadClass($name, $create = false, array $arguments = array())
 {
     $className = $this->_loader->load($name);
     // \MUtil_Echo::track($className);
     if (is_subclass_of($className, __CLASS__)) {
         $create = true;
         $arguments = array($this->_containers[0], $this->_dirs);
     } elseif (is_subclass_of($className, 'MUtil_Registry_TargetInterface')) {
         $create = true;
     }
     if (!$create) {
         return new \MUtil_Lazy_StaticCall($className);
     }
     $obj = $this->_loader->createClass($className, $arguments);
     if ($obj instanceof \MUtil_Registry_TargetInterface) {
         if (!$this->applySource($obj) && parent::$verbose) {
             \MUtil_Echo::r("Source apply to object of type {$name} failed.", __CLASS__ . '->' . __FUNCTION__);
         }
     }
     return $obj;
 }
 /**
  * Creates an object of the specified className seareching the loader dirs path
  *
  * @param string $className
  * @param mixed $paramOne Optional
  * @param mixed $paramTwo Optional
  * @return object
  */
 protected function createProjectClass($className, $paramOne = null, $paramTwo = null)
 {
     $arguments = func_get_args();
     array_shift($arguments);
     return $this->_projectLoader->createClass($className, $arguments);
 }