You are here

public function Container::__construct in Service Container 7

Same name in this branch
  1. 7 lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::__construct()
  2. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Container.php \Symfony\Component\DependencyInjection\Container::__construct()
  3. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php \Symfony\Component\DependencyInjection\Container::__construct()
Same name and namespace in other branches
  1. 7.2 lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container::__construct()

Constructs a new Container instance.

Parameters

array $container_definition: An array containing the following keys:

  • aliases: The aliases of the container.
  • parameters: The parameters of the container.
  • services: The service definitions of the container.
  • frozen: Whether the container definition came from a frozen container builder or not.
  • machine_format: Whether this container definition uses the optimized machine-readable container format.
1 method overrides Container::__construct()
PhpArrayContainer::__construct in lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
Constructs a new Container instance.

File

lib/Drupal/Component/DependencyInjection/Container.php, line 123
Contains \Drupal\Component\DependencyInjection\Container.

Class

Container
Provides a container optimized for Drupal's needs.

Namespace

Drupal\Component\DependencyInjection

Code

public function __construct(array $container_definition = array()) {
  if (!empty($container_definition) && (!isset($container_definition['machine_format']) || $container_definition['machine_format'] !== TRUE)) {
    throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \\Drupal\\Component\\DependencyInjection\\Dumper\\OptimizedPhpArrayDumper.');
  }
  $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array();
  $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array();
  $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array();
  $this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE;

  // Register the service_container with itself.
  $this->services['service_container'] = $this;
}