function DependencySerializationTraitPass::process

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass::process()
  2. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass::process()

File

core/lib/Drupal/Core/DependencyInjection/Compiler/DependencySerializationTraitPass.php, line 18

Class

DependencySerializationTraitPass
Sets the _serviceId property on all services.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  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);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.