Version 1
[yaffs-website] / web / core / lib / Drupal / Core / DependencyInjection / Compiler / DependencySerializationTraitPass.php
1 <?php
2
3 namespace Drupal\Core\DependencyInjection\Compiler;
4
5 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6 use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8 /**
9  * Sets the _serviceId property on all services.
10  *
11  * @see \Drupal\Core\DependencyInjection\DependencySerializationTrait
12  */
13 class DependencySerializationTraitPass implements CompilerPassInterface {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function process(ContainerBuilder $container) {
19     foreach ($container->getDefinitions() as $service_id => $definition) {
20       // Only add the property to services that are public (as private services
21       // can not be reloaded through Container::get()) and are objects.
22       if (!$definition->hasTag('parameter_service') && $definition->isPublic()) {
23         $definition->setProperty('_serviceId', $service_id);
24       }
25     }
26   }
27
28 }