protected function Kernel::buildContainer

Builds the service container.

Return value

ContainerBuilder The compiled service container

1 call to Kernel::buildContainer()
Kernel::initializeContainer in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php
Initializes the service container.
1 method overrides Kernel::buildContainer()
DrupalKernel::buildContainer in drupal/core/lib/Drupal/Core/DrupalKernel.php
Builds the service container.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php, line 651

Class

Kernel
The Kernel is the heart of the Symfony system.

Namespace

Symfony\Component\HttpKernel

Code

protected function buildContainer() {
  foreach (array(
    'cache' => $this
      ->getCacheDir(),
    'logs' => $this
      ->getLogDir(),
  ) as $name => $dir) {
    if (!is_dir($dir)) {
      if (false === @mkdir($dir, 0777, true)) {
        throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
      }
    }
    elseif (!is_writable($dir)) {
      throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
    }
  }
  $container = $this
    ->getContainerBuilder();
  $extensions = array();
  foreach ($this->bundles as $bundle) {
    if ($extension = $bundle
      ->getContainerExtension()) {
      $container
        ->registerExtension($extension);
      $extensions[] = $extension
        ->getAlias();
    }
    if ($this->debug) {
      $container
        ->addObjectResource($bundle);
    }
  }
  foreach ($this->bundles as $bundle) {
    $bundle
      ->build($container);
  }
  $container
    ->addObjectResource($this);

  // ensure these extensions are implicitly loaded
  $container
    ->getCompilerPassConfig()
    ->setMergePass(new MergeExtensionConfigurationPass($extensions));
  if (null !== ($cont = $this
    ->registerContainerConfiguration($this
    ->getContainerLoader($container)))) {
    $container
      ->merge($cont);
  }
  $container
    ->addCompilerPass(new AddClassesToCachePass($this));
  $container
    ->compile();
  return $container;
}