* @author Henrik Bjornskov * @author Magnus Nordlander */ class RegisterRoutersPass implements CompilerPassInterface { /** * @var string */ protected $chainRouterService; protected $routerTag; public function __construct($chainRouterService = 'cmf_routing.router', $routerTag = 'router') { $this->chainRouterService = $chainRouterService; $this->routerTag = $routerTag; } public function process(ContainerBuilder $container) { if (!$container->hasDefinition($this->chainRouterService)) { return; } $definition = $container->getDefinition($this->chainRouterService); foreach ($container->findTaggedServiceIds($this->routerTag) as $id => $attributes) { $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $definition->addMethodCall('add', array(new Reference($id), $priority)); } } }