Example #1
0
 /**
  * @return Router
  */
 public function getRouter()
 {
     if ($this->router === null) {
         $configName = 'hyperframework.web.router_class';
         $class = Config::getClass($configName);
         if ($class === null) {
             $class = 'Router';
             $namespace = Config::getAppRootNamespace();
             if ($namespace !== '' && $namespace !== '\\') {
                 $class = NamespaceCombiner::combine($namespace, $class);
             }
             if (class_exists($class) === false) {
                 throw new ClassNotFoundException("Router class '{$class}' does not exist," . " can be changed using config '{$configName}'.");
             }
         }
         $this->router = new $class($this);
     }
     return $this->router;
 }
 /**
  * @param string $subcommandName
  * @return string
  */
 protected function getDefaultClass($subcommandName = null)
 {
     $rootNamespace = Config::getAppRootNamespace();
     if ($subcommandName === null) {
         $class = 'Command';
         if ($rootNamespace !== '' && $rootNamespace !== '\\') {
             $class = NamespaceCombiner::combine($rootNamespace, $class);
         }
     } else {
         $tmp = ucwords(str_replace('-', ' ', $subcommandName));
         $class = str_replace(' ', '', $tmp) . 'Command';
         $namespace = 'Subcommands';
         $rootNamespace = Config::getAppRootNamespace();
         if ($rootNamespace !== '' && $rootNamespace !== '\\') {
             $namespace = NamespaceCombiner::combine($rootNamespace, $namespace);
         }
         $class = NamespaceCombiner::combine($namespace, $class);
     }
     return $class;
 }
 public function testCombineEmpty()
 {
     $name = 'Class';
     $name = NamespaceCombiner::combine($name, null);
     $this->assertSame('Class', $name);
 }
Example #4
0
 /**
  * @return string
  */
 private function getModuleNamespace()
 {
     $rootNamespace = 'Controllers';
     $appRootNamespace = Config::getAppRootNamespace();
     $rootNamespace = NamespaceCombiner::combine($appRootNamespace, $rootNamespace);
     $module = (string) $this->getModule();
     if ($module === '') {
         return $rootNamespace;
     }
     $tmp = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $module)));
     $namespace = str_replace(' ', '', ucwords(str_replace(['_', '-'], ' ', $tmp)));
     return NamespaceCombiner::combine($rootNamespace, $namespace);
 }