findDefinition('grumphp.parser.php.configurator.traverser'); foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) { $definition = $container->findDefinition($id); $this->markServiceAsPrototype($definition); foreach ($tags as $tag) { $alias = array_key_exists('alias', $tag) ? $tag['alias'] : $id; $traverserConfigurator->addMethodCall('registerVisitorId', [$alias, $id]); } } } /** * This method can be used to make the service shared cross-version. * From Symfony 2.8 the setShared method was available. * The 2.7 version is the LTS, so we still need to support it. * * @see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping * * @throws \GrumPHP\Exception\RuntimeException */ public function markServiceAsPrototype(Definition $definition): void { if (method_exists($definition, 'setShared')) { $definition->setShared(false); return; } if (method_exists($definition, 'setScope')) { $definition->setScope('prototype'); return; } throw new RuntimeException('The visitor could not be marked as unshared'); } }