You are here

public function ContainerBuilder::compile in Service Container 7

Same name in this branch
  1. 7 src/DependencyInjection/ContainerBuilder.php \Drupal\service_container\DependencyInjection\ContainerBuilder::compile()
  2. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::compile()
Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder::compile()

Compiles the container.

This method passes the container to compiler passes whose job is to manipulate and optimize the container.

The main compiler passes roughly do four things:

  • The extension configurations are merged;
  • Parameter values are resolved;
  • The parameter bag is frozen;
  • Extension loading is disabled.

@api

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php, line 604

Class

ContainerBuilder
ContainerBuilder is a DI container that provides an API to easily describe services.

Namespace

Symfony\Component\DependencyInjection

Code

public function compile() {
  $compiler = $this
    ->getCompiler();
  if ($this->trackResources) {
    foreach ($compiler
      ->getPassConfig()
      ->getPasses() as $pass) {
      $this
        ->addObjectResource($pass);
    }
  }
  $compiler
    ->compile($this);
  if ($this->trackResources) {
    foreach ($this->definitions as $definition) {
      if ($definition
        ->isLazy() && ($class = $definition
        ->getClass()) && class_exists($class)) {
        $this
          ->addClassResource(new \ReflectionClass($class));
      }
    }
  }
  $this->extensionConfigs = array();
  parent::compile();
}