Пример #1
0
 public function __construct(ServiceContainer $container = null)
 {
     $container = $container ?: ServiceContainer::getInstance();
     $this->formatter = $container['formatter'];
     // new Formatter;
     $this->writer = $container['writer'];
 }
Пример #2
0
 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');
 }
Пример #3
0
 public function __construct(ServiceContainer $container = null)
 {
     $container = $container ?: ServiceContainer::getInstance();
     $this->formatter = $container['formatter'];
     $this->console = $container['console'];
 }
Пример #4
0
<?php

$loader = (require 'vendor/autoload.php');
$loader->add('TestApp', 'tests');
$loader->add('DemoApp', 'tests');
$container = \CLIFramework\ServiceContainer::getInstance();
// $container['logger']->setQuiet();