class DependencySerializationTraitPass in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass
- 9 core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass
Sets the _serviceId property on all services.
Hierarchy
- class \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
Expanded class hierarchy of DependencySerializationTraitPass
See also
\Drupal\Core\DependencyInjection\DependencySerializationTrait
1 file declares its use of DependencySerializationTraitPass
- CoreServiceProvider.php in core/
lib/ Drupal/ Core/ CoreServiceProvider.php
File
- core/
lib/ Drupal/ Core/ DependencyInjection/ Compiler/ DependencySerializationTraitPass.php, line 13
Namespace
Drupal\Core\DependencyInjection\CompilerView source
class DependencySerializationTraitPass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
$decorations = new \SplPriorityQueue();
$order = PHP_INT_MAX;
foreach ($container
->getDefinitions() as $service_id => $definition) {
// Only add the property to services that are public (as private services
// can not be reloaded through Container::get()) and are objects.
if (!$definition
->hasTag('parameter_service') && $definition
->isPublic()) {
$definition
->setProperty('_serviceId', $service_id);
}
if ($decorated = $definition
->getDecoratedService()) {
$decorations
->insert([
$service_id,
$definition,
], [
$decorated[2],
--$order,
]);
}
}
foreach ($decorations as list($service_id, $definition)) {
list($inner, $renamedId) = $definition
->getDecoratedService();
if (!$renamedId) {
$renamedId = $service_id . '.inner';
}
$original = $container
->getDefinition($inner);
if ($original
->isPublic()) {
// The old service is renamed.
$original
->setProperty('_serviceId', $renamedId);
// The decorating service takes over the old ID.
$definition
->setProperty('_serviceId', $inner);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTraitPass:: |
public | function |