Creates a RouteCollection and populates it with the $routes provided.
Sets the banner to call showVersion().
If no help command is defined, defines one.
If no version command is defined, defines one.
public __construct ( string $name, string $version, array | Traversabl\Traversable $routes, Zend\Console\Adapter\AdapterInterface $console = null, ZF\Console\DispatcherInterface $dispatcher = null ) | ||
$name | string | Application name |
$version | string | Application version |
$routes | array | Traversabl\Traversable | Routes/route specifications to use for the application |
$console | Zend\Console\Adapter\AdapterInterface | Console adapter to use within the application |
$dispatcher | ZF\Console\DispatcherInterface | Configured dispatcher mapping routes to callables |
public function __construct() { $routes = [['name' => '<config> <output_file> [--strip]', 'short_description' => "Generate class cache based on <config> file into <output_file>.", 'handler' => [$this, 'generateDump']]]; parent::__construct('Cache dumper', 1.0, $routes, Console::getInstance()); $this->removeRoute('autocomplete'); $this->removeRoute('help'); $this->removeRoute('version'); }
/** * Initialize the application from single config * * @param array|Traversable $config Application config * @param Console $console Console adapter to use within the application * @param Dispatcher $dispatcher Configured dispatcher mapping routes to callables */ public function __construct($config, Console $console, Dispatcher $dispatcher = null) { if (!isset($config['name']) || !isset($config['version']) || !isset($config['routes'])) { throw new \InvalidArgumentException('Config must contains not empty fields: name, version, routes'); } if (!is_array($config['routes']) && !$config['routes'] instanceof Traversable) { throw new \InvalidArgumentException('Config must be provided as an array or Traversable object'); } parent::__construct($config['name'], $config['version'], $config['routes'], $console, $dispatcher); if (isset($config['service_manager']) && is_array($config['service_manager'])) { $sm = new ServiceManager(new Config($config['service_manager'])); $sm->setService('ApplicationConfig', $config); $this->setServiceLocator($sm); $this->getDispatcher()->setServiceLocator($sm); } }
/** * Overwritten constructor to simplify application instantiation * * @param string $routes * @param ConsoleInterface $console * @param Dispatcher $dispatcher */ public function __construct($routes, ConsoleInterface $console, Translator $translator = null, Dispatcher $dispatcher = null) { if ($translator) { $this->translator = $translator; $routes = $this->translateRoutes($routes); } // call parent constructor parent::__construct(self::NAME . ' - ' . self::SLOGAN, self::VERSION, $routes, $console, $dispatcher); // initialize routes $routes = []; // get all routes except standard version route foreach ($this->routeCollection->getRouteNames() as $routeName) { if ($routeName == 'version') { continue; } $routes[$routeName] = $this->routeCollection->getRoute($routeName); } // create new RouteCollection instance and add routes to it $this->routeCollection = new RouteCollection(); $this->setRoutes($routes); // change banner and footer $this->setBanner([$this, 'writeApplicationBanner']); $this->setFooter([$this, 'writeApplicationFooter']); }
public function __construct($name, $version, $routes, Console $console = null, $dispatcher = null) { parent::__construct($name, $version, $routes, $console, $dispatcher); }