Ejemplo n.º 1
0
 /**
  * Register commands to console.
  *
  * @param Console $console Windwalker console object.
  *
  * @return  void
  */
 public static function registerCommands(Console $console)
 {
     $reflection = new \ReflectionClass(get_called_class());
     $namespace = $reflection->getNamespaceName();
     $path = dirname($reflection->getFileName()) . '/Command';
     if (!is_dir($path)) {
         return;
     }
     $path = new PathLocator($path);
     /** @var \SplFileInfo $file */
     foreach ($path as $file) {
         if (!$file->isDir()) {
             continue;
         }
         $class = $namespace . '\\Command\\' . $file->getBasename() . '\\' . $file->getBasename() . 'Command';
         if (class_exists($class) && is_subclass_of($class, 'Windwalker\\Console\\Command\\AbstractCommand') && $class::$isEnabled) {
             $console->addCommand(new $class());
         }
     }
 }
 /**
  * Load the input object.
  *
  * @return  IO  The input object.
  */
 protected function loadInput()
 {
     return $this->app->getIO();
 }