public function __construct(ServiceContainer $container = null) { $container = $container ?: ServiceContainer::getInstance(); $this->formatter = $container['formatter']; // new Formatter; $this->writer = $container['writer']; }
public function __construct(Container $container = null, CommandBase $parent = null) { parent::__construct($parent); $this->serviceContainer = $container ?: ServiceContainer::getInstance(); if (isset($this->serviceContainer['event'])) { $this->eventService = $this->serviceContainer['event']; } else { $this->eventService = PhpEvent::getInstance(); } // initliaze command loader // TODO: if the service is not defined, we should create them with default settings. $this->loader = $this->serviceContainer['command_loader']; $this->logger = $this->serviceContainer['logger']; $this->formatter = $this->serviceContainer['formatter']; $this->globalConfig = $this->serviceContainer['config']; // get current class namespace, add {App}\Command\ to loader $appRefClass = new ReflectionClass($this); $appNs = $appRefClass->getNamespaceName(); $this->loader->addNamespace('\\' . $appNs . '\\Command'); $this->loader->addNamespace(array('\\CLIFramework\\Command')); $this->supportReadline = extension_loaded('readline'); }
public function __construct(ServiceContainer $container = null) { $container = $container ?: ServiceContainer::getInstance(); $this->formatter = $container['formatter']; $this->console = $container['console']; }
<?php $loader = (require 'vendor/autoload.php'); $loader->add('TestApp', 'tests'); $loader->add('DemoApp', 'tests'); $container = \CLIFramework\ServiceContainer::getInstance(); // $container['logger']->setQuiet();