dispatch() public method

{@inheritDoc}
public dispatch ( Route $route, Zend\Console\Adapter\AdapterInterface $console )
$route Route
$console Zend\Console\Adapter\AdapterInterface
Example #1
0
 /**
  * Run the application
  *
  * If no arguments are provided, pulls them from $argv, stripping the
  * script argument first.
  *
  * If the argument list is empty, displays a usage message.
  *
  * If arguments are provided, but no routes match, displays a usage message
  * and returns a status of 1.
  *
  * Otherwise, attempts to dispatch the matched command, returning the
  * execution status.
  *
  * @param array $args
  * @return int
  */
 public function run(array $args = null)
 {
     $this->initializeExceptionHandler();
     $this->setProcessTitle();
     if ($args === null) {
         global $argv;
         $args = array_slice($argv, 1);
     }
     if (empty($args)) {
         $this->showMessage($this->banner);
         $this->showUsageMessage();
         $this->showMessage($this->footer);
         return 0;
     }
     $route = $this->routeCollection->match($args);
     if (!$route instanceof Route) {
         $name = count($args) ? $args[0] : false;
         $route = $this->routeCollection->getRoute($name);
         if (!$route instanceof Route) {
             $this->showUnmatchedRouteMessage($args);
             return 1;
         }
         $this->showUsageMessageForRoute($route, true);
         return 1;
     }
     return $this->dispatcher->dispatch($route, $this->console);
 }
 /**
  * Process run
  * If the argument list is empty, displays a usage message.
  *
  * If arguments are provided, but no routes match, displays a usage message
  * and returns a status of 1.
  *
  * Otherwise, attempts to dispatch the matched command, returning the
  * execution status.
  *
  * @param array $args
  * @return int
  */
 protected function processRun(array $args)
 {
     if (empty($args)) {
         $this->showUsageMessage();
         return 0;
     }
     $route = $this->routeCollection->match($args);
     if (!$route instanceof Route) {
         $name = count($args) ? $args[0] : false;
         $route = $this->routeCollection->getRoute($name);
         if (!$route instanceof Route) {
             $this->showUnmatchedRouteMessage($args);
             return 1;
         }
         $this->showUsageMessageForRoute($route, true);
         return 1;
     }
     return $this->dispatcher->dispatch($route, $this->console);
 }