AcmePhp\Cli\Command\AbstractCommand::initializeContainer PHP Method

initializeContainer() private method

private initializeContainer ( ) : void
return void
    private function initializeContainer()
    {
        if ($this->configuration === null) {
            $this->initializeConfiguration();
        }
        $this->container = new ContainerBuilder();
        // Application services and parameters
        $this->container->set('app', $this->getApplication());
        $this->container->set('container', $this->container);
        $this->container->setParameter('app.version', Application::VERSION);
        $this->container->setParameter('app.storage_directory', $this->getApplication()->getStorageDirectory());
        $this->container->setParameter('app.backup_directory', $this->getApplication()->getBackupDirectory());
        // Load configuration
        $processor = new Processor();
        $config = $processor->processConfiguration(new AcmeConfiguration(), $this->configuration);
        $this->container->setParameter('storage.enable_backup', $config['storage']['enable_backup']);
        $this->container->setParameter('storage.post_generate', $config['storage']['post_generate']);
        $this->container->setParameter('monitoring.handlers', $config['monitoring']);
        // Load services
        $loader = new XmlFileLoader($this->container, new FileLocator(__DIR__ . '/../Resources'));
        $loader->load('services.xml');
        // Load solver
        $solvers = [];
        foreach ($this->container->findTaggedServiceIds('acmephp.challenge_solver') as $serviceId => $tags) {
            foreach ($tags as $tag) {
                if (!isset($tag['alias'])) {
                    throw new \InvalidArgumentException(sprintf('The tagged service "%s" must define have an alias', $serviceId));
                }
                $solvers[$tag['alias']] = $serviceId;
            }
        }
        $this->container->findDefinition('challenge_solver.locator')->replaceArgument(1, $solvers);
        // Inject output
        $this->container->set('output', $this->output);
    }