Robo\Robo::createDefaultContainer PHP Method

createDefaultContainer() public static method

Create a container and initiailze it. If you wish to *change* anything defined in the container, then you should call \Robo::configureContainer() instead of this function.
public static createDefaultContainer ( null | Symfony\Component\Console\Input\InputInterface $input = null, null | Symfony\Component\Console\Output\OutputInterface $output = null, null | Robo\Application $app = null, null | Robo\Config $config = null ) : League\Container\Container | League\Container\ContainerInterface
$input null | Symfony\Component\Console\Input\InputInterface
$output null | Symfony\Component\Console\Output\OutputInterface
$app null | Robo\Application
$config null | Robo\Config
return League\Container\Container | League\Container\ContainerInterface
    public static function createDefaultContainer($input = null, $output = null, $app = null, $config = null)
    {
        // Do not allow this function to be called more than once.
        if (static::hasContainer()) {
            return static::getContainer();
        }
        if (!$app) {
            $app = static::createDefaultApplication();
        }
        if (!$config) {
            $config = new Config();
        }
        // Set up our dependency injection container.
        $container = new Container();
        static::configureContainer($container, $app, $config, $input, $output);
        // Set the application dispatcher
        $app->setDispatcher($container->get('eventDispatcher'));
        return $container;
    }

Usage Example

Ejemplo n.º 1
0
 protected function _before()
 {
     $container = Robo::createDefaultContainer();
     $this->app = $container->get('application');
     $config = $container->get('config');
     $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);
     }
 }
All Usage Examples Of Robo\Robo::createDefaultContainer