src/DependencyInjection/ContainerInitializer/DefaultInitializer.php
public function initializeContainer(Application $application, array $extensions = array(), array $compilerPasses = array())
    {
        $container = $this->getContainerBuilder();
        $container->addObjectResource($application);
        $container->setParameter('app.env', $application->getEnvironment());
        $container->setParameter('app.debug', $application->isDebug());
        $container->setParameter('app.cache', $application->isCacheEnabled());
        $container->setParameter('app.root_dir', $application->getRootDir());
        $container->setParameter('app.cache_dir', $application->getCacheDir());
        $container->setParameter('app.log_dir', $application->getLogDir());

        $container->register('event_dispatcher', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher')
            ->setArguments(array(new Reference('service_container')));

        $container->register('app', 'Symfony\Component\HttpKernel\HttpKernelInterface')
            ->setSynthetic(true);

        $container->register('request', 'Symfony\Componenet\HttpKernel\Request')
            ->setSynthetic(true)
            ->setSynchronized(true)
            ->setScope('request');

        $container->addScope(new Scope('request'));

        $extensionAliases = array();
        foreach ($extensions as $extension) {
            $container->registerExtension($extension);
            $extensionAliases[] = $extension->getAlias();

            if ($extension instanceof CompilerAwareExtensionInterface) {
                $passes = $extension->getCompilerPasses();
                if (!is_array($passes)) {
                    $passes = array($passes);
                }

                $compilerPasses = array_merge($compilerPasses, $passes);
            }
        }

        $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensionAliases));
        $container->addCompilerPass(new RegisterListenersPass());

        foreach ($compilerPasses as $pass) {
            if (is_array($pass)) {
                $container->addCompilerPass($pass[0], $pass[1]);
            } else {
                $container->addCompilerPass($pass);
            }
        }

        $this->configProvider->load($container);

        $container->compile();

        return $container;
    }
public function initializeContainer(Application $application, array $extensions = array(), array $compilerPasses = array())
    {
        $container = $this->getContainerBuilder();
        $container->addObjectResource($application);
        $container->setParameter('app.env', $application->getEnvironment());
        $container->setParameter('app.debug', $application->isDebug());
        $container->setParameter('app.cache', $application->isCacheEnabled());
        $container->setParameter('app.root_dir', $application->getRootDir());
        $container->setParameter('app.cache_dir', $application->getCacheDir());
        $container->setParameter('app.log_dir', $application->getLogDir());

        $container->register('event_dispatcher', 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher')
            ->setArguments(array(new Reference('service_container')));

        $container->register('app', 'Symfony\Component\HttpKernel\HttpKernelInterface')
            ->setSynthetic(true);

        $container->register('request', 'Symfony\Componenet\HttpKernel\Request')
            ->setSynthetic(true)
            ->setSynchronized(true)
            ->setScope('request');

        $container->addScope(new Scope('request'));

        $extensionAliases = array();
        foreach ($extensions as $extension) {
            $container->registerExtension($extension);
            $extensionAliases[] = $extension->getAlias();

            if ($extension instanceof CompilerAwareExtensionInterface) {
                $passes = $extension->getCompilerPasses();
                if (!is_array($passes)) {
                    $passes = array($passes);
                }

                $compilerPasses = array_merge($compilerPasses, $passes);
            }
        }

        $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensionAliases));
        $container->addCompilerPass(new RegisterListenersPass());

        foreach ($compilerPasses as $pass) {
            if (is_array($pass)) {
                $container->addCompilerPass($pass[0], $pass[1]);
            } else {
                $container->addCompilerPass($pass);
            }
        }

        $this->configProvider->load($container);

        $container->compile();

        return $container;
    }
public function initializeContainer ( Application $ application , array $ extensions = array ( ) , array $ compilerPasses = array ( ) ) { $ container = $ this -> getContainerBuilder ( ) ; $ container -> addObjectResource ( $ application ) ; $ container -> setParameter ( 'app.env' , $ application -> getEnvironment ( ) ) ; $ container -> setParameter ( 'app.debug' , $ application -> isDebug ( ) ) ; $ container -> setParameter ( 'app.cache' , $ application -> isCacheEnabled ( ) ) ; $ container -> setParameter ( 'app.root_dir' , $ application -> getRootDir ( ) ) ; $ container -> setParameter ( 'app.cache_dir' , $ application -> getCacheDir ( ) ) ; $ container -> setParameter ( 'app.log_dir' , $ application -> getLogDir ( ) ) ; $ container -> register ( 'event_dispatcher' , 'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher' ) -> setArguments ( array ( new Reference ( 'service_container' ) ) ) ; $ container -> register ( 'app' , 'Symfony\Component\HttpKernel\HttpKernelInterface' ) -> setSynthetic ( true ) ; $ container -> register ( 'request' , 'Symfony\Componenet\HttpKernel\Request' ) -> setSynthetic ( true ) -> setSynchronized ( true ) -> setScope ( 'request' ) ; $ container -> addScope ( new Scope ( 'request' ) ) ; $ extensionAliases = array ( ) ; foreach ( $ extensions as $ extension ) { $ container -> registerExtension ( $ extension ) ; $ extensionAliases [ ] = $ extension -> getAlias ( ) ; if ( $ extension instanceof CompilerAwareExtensionInterface ) { $ passes = $ extension -> getCompilerPasses ( ) ; if ( ! is_array ( $ passes ) ) { $ passes = array ( $ passes ) ; } $ compilerPasses = array_merge ( $ compilerPasses , $ passes ) ; } } $ container -> getCompilerPassConfig ( ) -> setMergePass ( new MergeExtensionConfigurationPass ( $ extensionAliases ) ) ; $ container -> addCompilerPass ( new RegisterListenersPass ( ) ) ; foreach ( $ compilerPasses as $ pass ) { if ( is_array ( $ pass ) ) { $ container -> addCompilerPass ( $ pass [ 0 ] , $ pass [ 1 ] ) ; } else { $ container -> addCompilerPass ( $ pass ) ; } } $ this -> configProvider -> load ( $ container ) ; $ container -> compile ( ) ; return $ container ; }
Returns a fully built, ready to use Container

@param Application                   $application
@param array|ExtensionInterface[]    $extensions
@param array|CompilerPassInterface[] $compilerPasses

@return ContainerInterface
Returns a fully built ready to use Container