Exemplo n.º 1
0
 /**
  * @param string $ns Namespace's description
  * @param string $path Namespace's path
  * @throws Exception
  */
 public static function registerNamespace($ns, $path)
 {
     switch (true) {
         case self::$loader instanceof \Composer\Autoload\ClassLoader:
             self::$loader->add($ns, $path);
             break;
         case self::$loader instanceof \Zend\Loader\SplAutoloader:
             self::$loader->registerPrefix($ns, $path . '/' . $ns);
             break;
             // @TODO: This hasn't been tested nor confirmed. Must test & check if OK.
         // @TODO: This hasn't been tested nor confirmed. Must test & check if OK.
         case self::$loader instanceof \Symfony\Component\ClassLoader\UniversalClassLoader:
             self::$loader->registerNamespace($ns, $path);
             break;
         default:
             throw new \Exception('No Loader detected!');
     }
 }
Exemplo n.º 2
0
 /**
  * Class Prefix (Namespace) Register
  *
  * @param string $prefix
  * @param string $path
  * @throws \Exception
  */
 public function registerNamespace($prefix, $path)
 {
     switch (true) {
         // Zend Loader
         case self::$loader instanceof \Zend\Loader\SplAutoloader:
             self::$loader->registerPrefix($prefix, $path . '/' . str_replace('\\', '/', $prefix));
             break;
             // Composer Loader
         // Composer Loader
         case self::$loader instanceof \Composer\Autoload\ClassLoader:
             self::$loader->add($prefix, $path);
             break;
             // Symphony Loader
             // @TODO: Wonder if we should implement this as well or not
             // Throw exception for not finding a suported loader
         // Symphony Loader
         // @TODO: Wonder if we should implement this as well or not
         // Throw exception for not finding a suported loader
         default:
             throw new Exception\UndefinedClassLoaderException(sprintf('Unexpected ClassLoader type: \'%s\'', get_class(self::$loader)));
     }
     return $this;
 }