class ContainerBuilder in Service Container 7
Same name in this branch
- 7 src/DependencyInjection/ContainerBuilder.php \Drupal\service_container\DependencyInjection\ContainerBuilder
- 7 lib/Drupal/Core/DependencyInjection/ContainerBuilder.php \Drupal\Core\DependencyInjection\ContainerBuilder
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/ContainerBuilder.php \Symfony\Component\DependencyInjection\ContainerBuilder
Same name and namespace in other branches
- 7.2 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
2 files declare their use of ContainerBuilder
- DatabaseStorageExpirableTest.php in lib/
Drupal/ service_container/ Tests/ KeyValue/ DatabaseStorageExpirableTest.php - Contains Drupal\system\Tests\KeyValueStore\DatabaseStorageExpirableTest.
- ServiceContainerSymfonyServiceProvider.php in modules/
providers/ service_container_symfony/ src/ ServiceContainer/ ServiceProvider/ ServiceContainerSymfonyServiceProvider.php - Contains \Drupal\service_container_symfony\ServiceContainer\ServiceProvider\ServiceContainerSymfonyServiceProvider
File
- 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);
}
/**
* Synchronizes a service change.
*
* This method is a copy of the ContainerBuilder of symfony.
*
* This method updates all services that depend on the given
* service by calling all methods referencing it.
*
* @param string $id A service id
*/
private function synchronize($id) {
foreach ($this
->getDefinitions() as $definitionId => $definition) {
// only check initialized services
if (!$this
->initialized($definitionId)) {
continue;
}
foreach ($definition
->getMethodCalls() as $call) {
foreach ($call[1] as $argument) {
if ($argument instanceof Reference && $id == (string) $argument) {
$this
->callMethod($this
->get($definitionId), $call);
}
}
}
}
}
/**
* 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() {
trigger_error('The container was serialized.', E_USER_ERROR);
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. | |
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. | |
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 | ||
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. Overrides ContainerBuilder:: |
|
ContainerBuilder:: |
public | function | ||
ContainerBuilder:: |
public | function |