Inheritance: implements Zend\ServiceManager\ServiceLocatorAwareInterface, use trait Zend\ServiceManager\ServiceLocatorAwareTrait
 /**
  * Map a route handler
  *
  * If a given route specification has a "handler" entry, and the dispatcher
  * does not currently have a handler for that command, map it.
  *
  * @param array $route
  */
 protected function mapRouteHandler(array $route)
 {
     if (!isset($route['handler'])) {
         return;
     }
     $command = $route['name'];
     if ($this->dispatcher->has($command)) {
         return;
     }
     $this->dispatcher->map($command, $route['handler']);
 }
 /**
  * @group 7
  */
 public function testHandlersConfiguredViaRoutesDoNotOverwriteThoseAlreadyInDispatcher()
 {
     $phpunit = $this;
     $dispatcher = new Dispatcher();
     $dispatcher->map('test', function ($route, $console) use($phpunit) {
         $phpunit->assertEquals('test', $route->getName());
         return 2;
     });
     $routes = [['name' => 'test', 'route' => 'test', 'description' => 'Test handler capabilities', 'short_description' => 'Test handler capabilities', 'handler' => function ($route, $console) use($phpunit) {
         $phpunit->fail('Handler from route configuration was invoked when it should not be');
         return 3;
     }]];
     $application = new Application('ZFConsoleApplication', $this->version, $routes, $this->console, $dispatcher);
     $this->assertEquals(2, $application->run(['test']));
 }
Example #3
0
#!/usr/bin/env php
<?php 
use Zend\Console\Console;
use ZF\Console\Application;
use ZF\Console\Dispatcher;
use ZF\Maintainer\Components;
use ZF\Maintainer\Release;
require __DIR__ . '/../vendor/autoload.php';
$version = '0.0.1';
$dispatcher = new Dispatcher();
$dispatcher->map('lts-release', new Release(include __DIR__ . '/../config/components.php'));
$dispatcher->map('lts-components', new Components(include __DIR__ . '/../config/components.php'));
$application = new Application('ZF Maintainer', $version, include __DIR__ . '/../config/routes.php', Console::getInstance(), $dispatcher);
$exit = $application->run();
exit($exit);