public function buildContainer($dir)
    {
        // load the container
        $container = new ContainerBuilder();

        // setup basic container compiler passes
        $container->addCompilerPass(new EventListenerPass());
        $container->addCompilerPass(new TemplatingEnginePass());

        $configDir = $dir.'/config';
        // set the key as a parameter
        $container->setParameter('base_dir', $dir);
        $container->setParameter('config_dir', $configDir);

        // load base services
        $configdirs = array(__DIR__.'/Resources/config', $dir, $configDir);
        $loader = new XmlFileLoader($container, new FileLocator($configdirs));
        $loader->load('services.xml');

        // register extensions
        foreach ($container->findTaggedServiceIds('extension') as $id => $attributes) {
            $extension = $container->get($id);
            if (!$extension instanceof BaseExtensionInterface) {
                throw new \RuntimeException("Invalid extension with id '${id}'.");
            }
            $container->registerExtension($extension);
        }

        // preload the extensions
        foreach ($container->getExtensions() as $extension) {
            if ($extension instanceof ExtensionInterface) {
                $extension->preload($container);
            }
        }

        return $container;
    }
public function buildContainer($dir)
    {
        // load the container
        $container = new ContainerBuilder();

        // setup basic container compiler passes
        $container->addCompilerPass(new EventListenerPass());
        $container->addCompilerPass(new TemplatingEnginePass());

        $configDir = $dir.'/config';
        // set the key as a parameter
        $container->setParameter('base_dir', $dir);
        $container->setParameter('config_dir', $configDir);

        // load base services
        $configdirs = array(__DIR__.'/Resources/config', $dir, $configDir);
        $loader = new XmlFileLoader($container, new FileLocator($configdirs));
        $loader->load('services.xml');

        // register extensions
        foreach ($container->findTaggedServiceIds('extension') as $id => $attributes) {
            $extension = $container->get($id);
            if (!$extension instanceof BaseExtensionInterface) {
                throw new \RuntimeException("Invalid extension with id '${id}'.");
            }
            $container->registerExtension($extension);
        }

        // preload the extensions
        foreach ($container->getExtensions() as $extension) {
            if ($extension instanceof ExtensionInterface) {
                $extension->preload($container);
            }
        }

        return $container;
    }
public function buildContainer ( $ dir ) { // load the container $ container = new ContainerBuilder ( ) ; // setup basic container compiler passes $ container -> addCompilerPass ( new EventListenerPass ( ) ) ; $ container -> addCompilerPass ( new TemplatingEnginePass ( ) ) ; $ configDir = $ dir . '/config' ; // set the key as a parameter $ container -> setParameter ( 'base_dir' , $ dir ) ; $ container -> setParameter ( 'config_dir' , $ configDir ) ; // load base services $ configdirs = array ( __DIR__ . '/Resources/config' , $ dir , $ configDir ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( $ configdirs ) ) ; $ loader -> load ( 'services.xml' ) ; // register extensions foreach ( $ container -> findTaggedServiceIds ( 'extension' ) as $ id => $ attributes ) { $ extension = $ container -> get ( $ id ) ; if ( ! $ extension instanceof BaseExtensionInterface ) { throw new \ RuntimeException ( "Invalid extension with id '${id}'." ) ; } $ container -> registerExtension ( $ extension ) ; } // preload the extensions foreach ( $ container -> getExtensions ( ) as $ extension ) { if ( $ extension instanceof ExtensionInterface ) { $ extension -> preload ( $ container ) ; } } return $ container ; }
Builds the dependency injection container

@param  string             $dir the path to the base of the site configuration
@return ContainerInterface the new container

@throws \RuntimeException when a service tagged as an extension does not implement ExtensionInterface
Builds the dependency injection container