DependencySerializationTraitPass.php in Drupal 10
File
core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php
View source
<?php
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class DependencySerializationTraitPass implements CompilerPassInterface {
public function process(ContainerBuilder $container) {
$decorations = new \SplPriorityQueue();
$order = PHP_INT_MAX;
foreach ($container
->getDefinitions() as $service_id => $definition) {
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()) {
$original
->setProperty('_serviceId', $renamedId);
$definition
->setProperty('_serviceId', $inner);
}
}
}
}