/**
  * Handle request in stack
  * 
  * @param   object  $request  Request
  * @return  mixed
  */
 public function handle(Request $request)
 {
     $response = $this->next($request);
     $class = $this->app->get('arguments')->get('class');
     $task = $this->app->get('arguments')->get('task');
     $command = new $class($this->app->get('output'), $this->app->get('arguments'));
     $shortName = strtolower(with(new \ReflectionClass($command))->getShortName());
     // Fire default before event
     Event::fire($shortName . '.' . 'before' . ucfirst($task));
     $command->{$task}();
     // Fire default after event
     Event::fire($shortName . '.' . 'after' . ucfirst($task));
     $this->app->get('output')->render();
     return $response;
 }
 /**
  * Handle request in stack
  * 
  * @param   object  $request  Request
  * @return  mixed
  */
 public function handle(Request $request)
 {
     $response = $this->next($request);
     $arguments = $this->app['arguments'];
     $output = $this->app['output'];
     // Check for interactivity flag and set on output accordingly
     if ($arguments->getOpt('non-interactive')) {
         $output->makeNonInteractive();
     }
     // Check for color flag and set on output accordingly
     if ($arguments->getOpt('no-colors')) {
         $output->makeUnColored();
     }
     // If task is help, set the output to our output class with extra methods for rendering help doc
     if ($arguments->get('task') == 'help') {
         $output = $output->getHelpOutput();
     }
     // If the format opt is present, try to use the appropriate output subclass
     if ($arguments->getOpt('format')) {
         $output = $output->getOutputFormatter($arguments->getOpt('format'));
     }
     // Register any user specific events
     if ($hooks = Config::get('hooks')) {
         foreach ($hooks as $trigger => $scripts) {
             foreach ($scripts as $script) {
                 Event::register($trigger, function () use($script, $output) {
                     if ($output->getMode() != 'minimal') {
                         $output->addLine("Running '{$script}'");
                     }
                     shell_exec(escapeshellcmd($script));
                 });
             }
         }
     }
     // Reset the output stored on the application
     $this->app->forget('output');
     $this->app->set('output', $output);
     return $response;
 }
示例#3
0
 /**
  * Dispatch the application
  *
  * @param  string $component the component to dispatch (does not apply here)
  * @return void
  */
 public function dispatch($component = null)
 {
     $class = App::get('arguments')->get('class');
     $task = App::get('arguments')->get('task');
     $command = new $class(App::get('output'), App::get('arguments'));
     $shortName = strtolower(with(new \ReflectionClass($command))->getShortName());
     // Fire default before event
     Event::fire($shortName . '.' . 'before' . ucfirst($task));
     $command->{$task}();
     // Fire default after event
     Event::fire($shortName . '.' . 'after' . ucfirst($task));
 }