Robo\Robo::configureContainer PHP Method

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
    public static function configureContainer(ContainerInterface $container, SymfonyApplication $app, Config $config, $input = null, $output = null)
    {
        // Self-referential container refernce for the inflector
        $container->add('container', $container);
        static::setContainer($container);
        // Create default input and output objects if they were not provided
        if (!$input) {
            $input = new StringInput('');
        }
        if (!$output) {
            $output = new \Symfony\Component\Console\Output\ConsoleOutput();
        }
        $config->setDecorated($output->isDecorated());
        $container->share('application', $app);
        $container->share('config', $config);
        $container->share('input', $input);
        $container->share('output', $output);
        // Register logging and related services.
        $container->share('logStyler', \Robo\Log\RoboLogStyle::class);
        $container->share('logger', \Robo\Log\RoboLogger::class)->withArgument('output')->withMethodCall('setLogOutputStyler', ['logStyler']);
        $container->add('progressBar', \Symfony\Component\Console\Helper\ProgressBar::class)->withArgument('output');
        $container->share('progressIndicator', \Robo\Common\ProgressIndicator::class)->withArgument('progressBar')->withArgument('output');
        $container->share('resultPrinter', \Robo\Log\ResultPrinter::class);
        $container->add('simulator', \Robo\Task\Simulator::class);
        $container->share('globalOptionsEventListener', \Robo\GlobalOptionsEventListener::class);
        $container->share('collectionProcessHook', \Robo\Collection\CollectionProcessHook::class);
        $container->share('hookManager', \Consolidation\AnnotatedCommand\Hooks\HookManager::class)->withMethodCall('addResultProcessor', ['collectionProcessHook', '*']);
        $container->share('alterOptionsCommandEvent', \Consolidation\AnnotatedCommand\Options\AlterOptionsCommandEvent::class)->withArgument('application');
        $container->share('eventDispatcher', \Symfony\Component\EventDispatcher\EventDispatcher::class)->withMethodCall('addSubscriber', ['globalOptionsEventListener'])->withMethodCall('addSubscriber', ['alterOptionsCommandEvent'])->withMethodCall('addSubscriber', ['hookManager']);
        $container->share('formatterManager', \Consolidation\OutputFormatters\FormatterManager::class)->withMethodCall('addDefaultFormatters', [])->withMethodCall('addDefaultSimplifiers', []);
        $container->share('prepareTerminalWidthOption', \Consolidation\AnnotatedCommand\Options\PrepareTerminalWidthOption::class)->withMethodCall('setApplication', ['application']);
        $container->share('commandProcessor', \Consolidation\AnnotatedCommand\CommandProcessor::class)->withArgument('hookManager')->withMethodCall('setFormatterManager', ['formatterManager'])->withMethodCall('addPrepareFormatter', ['prepareTerminalWidthOption'])->withMethodCall('setDisplayErrorFunction', [function ($output, $message) use($container) {
            $logger = $container->get('logger');
            $logger->error($message);
        }]);
        $container->share('commandFactory', \Consolidation\AnnotatedCommand\AnnotatedCommandFactory::class)->withMethodCall('setCommandProcessor', ['commandProcessor']);
        $container->add('collection', \Robo\Collection\Collection::class);
        $container->add('collectionBuilder', \Robo\Collection\CollectionBuilder::class);
        static::addInflectors($container);
        // Make sure the application is appropriately initialized.
        $app->setAutoExit(false);
    }

Usage Example

Esempio n. 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');
 }
All Usage Examples Of Robo\Robo::configureContainer