class ContainerBuilder in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/dependency-injection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder
- 8 core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder
Drupal's dependency injection container builder.
@todo Submit upstream patches to Symfony to not require these overrides.
Hierarchy
- class \Symfony\Component\DependencyInjection\ContainerBuilder extends \Symfony\Component\DependencyInjection\Container implements TaggedContainerInterface
- class \Drupal\Core\DependencyInjection\ContainerBuilder
Expanded class hierarchy of ContainerBuilder
Related topics
97 files declare their use of ContainerBuilder
- AcceptHeaderRoutingTestServiceProvider.php in core/
modules/ system/ tests/ modules/ accept_header_routing_test/ src/ AcceptHeaderRoutingTestServiceProvider.php - Contains \Drupal\accept_header_routing_test\AcceptHeaderRoutingTestServiceProvider.
- AccessResultTest.php in core/
tests/ Drupal/ Tests/ Core/ Access/ AccessResultTest.php - Contains \Drupal\Tests\Core\Access\AccessResultTest.
- BaseFieldDefinitionTest.php in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - Contains \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest.
- BaseFieldDefinitionTestBase.php in core/
tests/ Drupal/ Tests/ Core/ Field/ BaseFieldDefinitionTestBase.php - Contains \Drupal\Tests\Core\Field\BaseFieldDefinitionTestBase.
- BlockConfigEntityUnitTest.php in core/
modules/ block/ tests/ src/ Unit/ BlockConfigEntityUnitTest.php - Contains \Drupal\Tests\block\Unit\BlockConfigEntityUnitTest.
File
- core/
lib/ Drupal/ Core/ DependencyInjection/ ContainerBuilder.php, line 22 - Contains \Drupal\Core\DependencyInjection\ContainerBuilder.
Namespace
Drupal\Core\DependencyInjectionView source
class ContainerBuilder extends SymfonyContainerBuilder {
/**
* {@inheritdoc}
*/
public function __construct(ParameterBagInterface $parameterBag = NULL) {
$this
->setResourceTracking(FALSE);
parent::__construct($parameterBag);
}
/**
* Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set().
*
* Drupal's container builder can be used at runtime after compilation, so we
* override Symfony's ContainerBuilder's restriction on setting services in a
* frozen builder.
*
* @todo Restrict this to synthetic services only. Ideally, the upstream
* ContainerBuilder class should be fixed to allow setting synthetic
* services in a frozen builder.
*/
public function set($id, $service, $scope = self::SCOPE_CONTAINER) {
if (strtolower($id) !== $id) {
throw new \InvalidArgumentException("Service ID names must be lowercase: {$id}");
}
SymfonyContainer::set($id, $service, $scope);
// Ensure that the _serviceId property is set on synthetic services as well.
if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) {
$this->services[$id]->_serviceId = $id;
}
}
/**
* {@inheritdoc}
*/
public function register($id, $class = null) {
if (strtolower($id) !== $id) {
throw new \InvalidArgumentException("Service ID names must be lowercase: {$id}");
}
return parent::register($id, $class);
}
/**
* {@inheritdoc}
*/
public function setParameter($name, $value) {
if (strtolower($name) !== $name) {
throw new \InvalidArgumentException("Parameter names must be lowercase: {$name}");
}
parent::setParameter($name, $value);
}
/**
* A 1to1 copy of parent::callMethod.
*/
protected function callMethod($service, $call) {
$services = self::getServiceConditionals($call[1]);
foreach ($services as $s) {
if (!$this
->has($s)) {
return;
}
}
call_user_func_array(array(
$service,
$call[0],
), $this
->resolveServices($this
->getParameterBag()
->resolveValue($call[1])));
}
/**
* {@inheritdoc}
*/
public function __sleep() {
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
private | property | ||
ContainerBuilder:: |
public | function | Adds the service aliases. | |
ContainerBuilder:: |
public | function | Adds the given class hierarchy as resources. | |
ContainerBuilder:: |
public | function | Adds a compiler pass. | |
ContainerBuilder:: |
public | function | Adds the service definitions. | |
ContainerBuilder:: |
public | function | ||
ContainerBuilder:: |
public | function | Adds the object class hierarchy as resources. | |
ContainerBuilder:: |
public | function | Adds a resource for this configuration. | |
ContainerBuilder:: |
protected | function |
A 1to1 copy of parent::callMethod. Overrides ContainerBuilder:: |
|
ContainerBuilder:: |
public | function | Compiles the container. | |
ContainerBuilder:: |
public | function | Creates a service for a service definition. | |
ContainerBuilder:: |
public | function | Gets a service definition by id or alias. | |
ContainerBuilder:: |
public | function |
Returns service ids for a given tag. Overrides TaggedContainerInterface:: |
|
ContainerBuilder:: |
public | function | Returns all tags the defined services use. | |
ContainerBuilder:: |
public | function |
Gets a service. Overrides ContainerInterface:: |
|
ContainerBuilder:: |
public | function | Gets an alias. | |
ContainerBuilder:: |
public | function | Gets all defined aliases. | |
ContainerBuilder:: |
public | function | Returns the compiler. | |
ContainerBuilder:: |
public | function | Returns the compiler pass config which can then be modified. | |
ContainerBuilder:: |
public | function | Gets a service definition. | |
ContainerBuilder:: |
public | function | Gets all service definitions. | |
ContainerBuilder:: |
private | function | ||
ContainerBuilder:: |
public | function | ||
ContainerBuilder:: |
public | function | Returns an extension by alias or namespace. | |
ContainerBuilder:: |
public | function | Returns the configuration array for the given extension. | |
ContainerBuilder:: |
public | function | Returns all registered extensions. | |
ContainerBuilder:: |
private | function | Retrieves the currently set proxy instantiator or instantiates one. | |
ContainerBuilder:: |
public | function | Returns an array of resources loaded to build this configuration. | |
ContainerBuilder:: |
public | function | Returns all Scope children. | |
ContainerBuilder:: |
public | function | Returns all Scopes. | |
ContainerBuilder:: |
public static | function | Returns the Service Conditionals. | |
ContainerBuilder:: |
public | function | Gets all service ids. | |
ContainerBuilder:: |
public | function |
Returns true if the given service is defined. Overrides ContainerInterface:: |
|
ContainerBuilder:: |
public | function | Returns true if an alias exists under the given identifier. | |
ContainerBuilder:: |
public | function | Returns true if a service definition exists under the given identifier. | |
ContainerBuilder:: |
public | function | Checks if we have an extension. | |
ContainerBuilder:: |
public | function | Checks if resources are tracked. | |
ContainerBuilder:: |
public | function | Loads the configuration for an extension. | |
ContainerBuilder:: |
public | function | Merges a ContainerBuilder with the current ContainerBuilder configuration. | |
ContainerBuilder:: |
public | function | Prepends a config array to the configs of the given extension. | |
ContainerBuilder:: |
public | function |
Registers a service definition. Overrides ContainerBuilder:: |
|
ContainerBuilder:: |
public | function | Registers an extension. | |
ContainerBuilder:: |
public | function | Removes an alias. | |
ContainerBuilder:: |
public | function | Removes a service definition. | |
ContainerBuilder:: |
public | function | Replaces service references by the real service instance and evaluates expressions. | |
ContainerBuilder:: |
public | function |
Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set(). Overrides ContainerBuilder:: |
|
ContainerBuilder:: |
public | function | Sets an alias for an existing service. | |
ContainerBuilder:: |
public | function | Sets the service aliases. | |
ContainerBuilder:: |
public | function | Sets a service definition. | |
ContainerBuilder:: |
public | function | Sets the service definitions. | |
ContainerBuilder:: |
public | function |
Sets a parameter. Overrides ContainerInterface:: |
|
ContainerBuilder:: |
public | function | Sets the instantiator to be used when fetching proxies. | |
ContainerBuilder:: |
public | function | Sets the resources for this configuration. | |
ContainerBuilder:: |
public | function | Sets the track resources flag. | |
ContainerBuilder:: |
private | function | Shares a given service in the container. | |
ContainerBuilder:: |
private | function | Synchronizes a service change. | |
ContainerBuilder:: |
public | function | Constructor. | |
ContainerBuilder:: |
public | function | ||
ContainerInterface:: |
public | function | Adds a scope to the container. | 2 |
ContainerInterface:: |
public | function | Enters the given scope. | 2 |
ContainerInterface:: |
constant | |||
ContainerInterface:: |
public | function | Gets a parameter. | 2 |
ContainerInterface:: |
public | function | Checks if a parameter exists. | 2 |
ContainerInterface:: |
public | function | Whether this container has the given scope. | 2 |
ContainerInterface:: |
constant | |||
ContainerInterface:: |
public | function | Determines whether the given scope is currently active. | 2 |
ContainerInterface:: |
public | function | Leaves the current scope, and re-enters the parent scope. | 2 |
ContainerInterface:: |
constant | |||
ContainerInterface:: |
constant | |||
ContainerInterface:: |
constant |