Example #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;
 }
 /**
  * Add prefixed paths to the registry of paths
  *
  * @param string $prefix
  * @param mixed $paths String or an array of strings
  * @param boolean $prepend Put path at the beginning of the stack (has no effect when prefix / dir already set)
  * @return \Gems_Loader_LoaderAbstract (continuation pattern)
  */
 public function addPrefixPath($prefix, $path, $prepend = true)
 {
     if ($this->cascade) {
         $newPrefix = $prefix . '_' . $this->cascade;
         $newPath = $path . '/' . strtr($this->cascade, '_', '/');
     } else {
         $newPrefix = $prefix;
         $newPath = $path;
     }
     if ($prepend) {
         $this->_dirs = array($newPrefix => $newPath) + $this->_dirs;
     } else {
         $this->_dirs[$newPrefix] = $newPath;
     }
     $this->_loader->addPrefixPath($newPrefix, $newPath, $prepend);
     if (\MUtil_Registry_Source::$verbose) {
         \MUtil_Echo::r($this->_dirs, '$this->_dirs in ' . get_class($this) . '->' . __FUNCTION__ . '():');
     }
     return $this;
 }
Example #3
0
 /**
  * Remove a prefix (or prefixed-path) from the registry
  *
  * @param string $prefix
  * @param string $path OPTIONAL
  * @return \MUtil_Snippets_SnippetLoaderInterface
  */
 public function removePrefixPath($prefix, $path = null)
 {
     $this->loader->removePrefixPath($prefix, $path);
     return $this;
 }
 /**
  * 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);
 }