Ejemplo n.º 1
0
 public function setupServices(ContainerInterface $container)
 {
     $container->setShared('config', function () {
         return new Processor();
     });
     $container->setShared('dispatcher', function ($c) {
         $dispatcher = new EventDispatcher();
         array_map(array($dispatcher, 'addSubscriber'), $c->getByPrefix('dispatcher.listeners'));
         return $dispatcher;
     });
     $container->setShared('logger.handler', function ($c) {
         $format = "%start_tag%[%datetime%][%channel%][%level_name%] %message% %context% %extra% %end_tag%\n";
         $formatter = new ConsoleFormatter($format);
         $handler = new ConsoleHandler(null, true);
         $handler->setFormatter($formatter);
         return $handler;
     });
     $container->setShared('logger', function ($c) {
         $logger = new Logger('Main');
         $logger->pushHandler($c->get('logger.handler'));
         return $logger;
     });
     $container->setShared('listen.listener', function ($c) {
         $listener = Listen::to(getcwd());
         $options = $c->get('phpguard')->getOptions();
         foreach ($options['ignores'] as $ignored) {
             $listener->ignores($ignored);
         }
         $phpguard = $c->get('phpguard');
         $listener->latency($options['latency']);
         $listener->callback(array($phpguard, 'listen'));
         return $listener;
     });
     $container->setShared('listen.adapter', function () {
         $adapter = Listen::getDefaultAdapter();
         return $adapter;
     });
     $container->setShared('locator', function () {
         $locator = new Locator();
         return $locator;
     });
     $container->setShared('dispatcher.listeners.locator', function ($c) {
         return $c->get('locator');
     });
     $container->setShared('runner.logger', function ($c) {
         $logger = new Logger('Runner');
         $logger->pushHandler($c->get('logger.handler'));
         return $logger;
     });
     $container->setShared('runner', function () {
         return new Runner();
     });
     $container->setShared('filesystem', function () {
         return new Filesystem();
     });
     CodeCoverageSession::setupContainer($container);
 }
Ejemplo n.º 2
0
 public function evaluate()
 {
     if (!isset($this->adapter)) {
         $this->adapter = Listen::getDefaultAdapter();
         $this->adapter->initialize($this);
     }
     if ($this->logger) {
         $this->adapter->setLogger($this->logger);
     }
     $this->adapter->evaluate();
     $this->changeSet = $this->adapter->getChangeSet();
     $this->notify();
 }