public function ContainerBuilder::getContainerDefinition in Service Container 7.2
Same name and namespace in other branches
- 7 src/DependencyInjection/ContainerBuilder.php \Drupal\service_container\DependencyInjection\ContainerBuilder::getContainerDefinition()
Returns the fully build container definition.
Return value
array An associative array with the following keys:
- parameters: The parameters of the container, simple k/v
- services: The services of the container.
Overrides ContainerBuilderInterface::getContainerDefinition
See also
\Drupal\service_container\DependencyInjection\ServiceProviderInterface
2 calls to ContainerBuilder::getContainerDefinition()
- CachedContainerBuilder::getContainerDefinition in src/
DependencyInjection/ CachedContainerBuilder.php - Returns the fully build container definition.
- ContainerBuilder::compile in src/
DependencyInjection/ ContainerBuilder.php - Compiles the container builder to a new container.
1 method overrides ContainerBuilder::getContainerDefinition()
- CachedContainerBuilder::getContainerDefinition in src/
DependencyInjection/ CachedContainerBuilder.php - Returns the fully build container definition.
File
- src/
DependencyInjection/ ContainerBuilder.php, line 50 - Contains \Drupal\service_container\DependencyInjection\ContainerBuilder
Class
- ContainerBuilder
- ContainerBuilder retrieves container definitions from service providers to build a Container.
Namespace
Drupal\service_container\DependencyInjectionCode
public function getContainerDefinition() {
$definitions = $this->serviceProviderManager
->getDefinitions();
$container_definition = array();
$service_providers = array();
// Populate service providers.
foreach ($definitions as $plugin_id => $definition) {
$service_providers[$plugin_id] = $this->serviceProviderManager
->createInstance($plugin_id);
}
// Get container definition of each service provider and merge them.
foreach ($definitions as $plugin_id => $definition) {
$service_provider = $service_providers[$plugin_id];
$container_definition = NestedArray::mergeDeep($container_definition, $service_provider
->getContainerDefinition());
}
$container_definition += array(
'services' => array(),
'parameters' => array(),
);
// @codeCoverageIgnore
// Find and setup tags for container altering.
$container_definition['tags'] = array();
// Setup the tags structure.
foreach ($container_definition['services'] as $service => $definition) {
if (isset($definition['tags'])) {
foreach ($definition['tags'] as $tag) {
$tag_name = $tag['name'];
unset($tag['name']);
$container_definition['tags'][$tag_name][$service][] = $tag;
}
}
}
// Ensure container definition can be altered.
foreach ($definitions as $plugin_id => $definition) {
$service_provider = $service_providers[$plugin_id];
$service_provider
->alterContainerDefinition($container_definition);
}
// Last give a chance for traditional modules to alter this.
$this
->moduleAlter($container_definition);
// Remove the tags again, not needed for the final build of the container.
unset($container_definition['tags']);
return $container_definition;
}