configureContainer() public static method

IMPORTANT: after calling this method, clients MUST call: $dispatcher = $container->get('eventDispatcher'); $app->setDispatcher($dispatcher); Any modification to the container should be done prior to fetching objects from it. It is recommended to use \Robo::createDefaultContainer() instead, which does all required setup for the caller, but has the limitation that the container it creates can only be extended, not modified.
public static configureContainer ( League\Container\ContainerInterface $container, Application $app, robo\Config $config, null | Symfony\Component\Console\Input\InputInterface $input = null, null | Symfony\Component\Console\Output\OutputInterface $output = null )
$container League\Container\ContainerInterface
$app Symfony\Component\Console\Application
$config robo\Config
$input null | Symfony\Component\Console\Input\InputInterface
$output null | Symfony\Component\Console\Output\OutputInterface
示例#1
0
 public function initSeeInOutputTrait($container, $input = null)
 {
     $this->capturedOutput = '';
     $this->testPrinter = new BufferedOutput(OutputInterface::VERBOSITY_DEBUG);
     $app = Robo::createDefaultApplication();
     $config = new \Robo\Config();
     \Robo\Robo::configureContainer($container, $app, $config, $input, $this->testPrinter);
     // Set the application dispatcher
     $app->setDispatcher($container->get('eventDispatcher'));
     $this->logger = $container->get('logger');
 }
示例#2
0
 public function initSeeInOutputTrait($container, $input = null)
 {
     $this->capturedOutput = '';
     $this->testPrinter = new BufferedOutput(OutputInterface::VERBOSITY_DEBUG);
     $this->logger = new \Robo\Log\RoboLogger($this->testPrinter);
     $progressBar = new \Symfony\Component\Console\Helper\ProgressBar($this->testPrinter);
     \Robo\Robo::configureContainer($container, $input, $this->testPrinter);
     $container->add('output', $this->testPrinter);
     $container->add('progressBar', $progressBar);
     $container->add('progressIndicator', new \Robo\Common\ProgressIndicator($progressBar, $this->testPrinter));
 }
示例#3
0
 protected function _before()
 {
     $container = new Container();
     \Robo\Robo::configureContainer($container);
     \Robo\Robo::setContainer($container);
     $this->app = $container->get('application');
     $this->commandFactory = $container->get('commandFactory');
     $this->roboCommandFileInstance = new TestedRoboFile();
     $builder = $container->get('collectionBuilder', [$this->roboCommandFileInstance]);
     $this->roboCommandFileInstance->setBuilder($builder);
     $commandList = $this->commandFactory->createCommandsFromClass($this->roboCommandFileInstance);
     foreach ($commandList as $command) {
         $this->app->add($command);
     }
 }
示例#4
0
<?php

// Here you can initialize variables that will for your tests
use Robo\Robo;
use Robo\Runner;
use League\Container\Container;
use Symfony\Component\Console\Input\StringInput;
$container = new Container();
$input = new StringInput('');
Robo::configureContainer($container, $input);
Robo::setContainer($container);