hasDefinition('chill_main.timeline_builder')) { throw new \LogicException('service chill_main.timeline_builder is not defined.'); } $definition = $container->getDefinition( 'chill_main.timeline_builder' ); $taggedServices = $container->findTaggedServiceIds( 'chill.timeline' ); foreach ($taggedServices as $id => $tagAttributes) { foreach ($tagAttributes as $attributes) { if (!isset($attributes['context'])) { throw new \LogicException("the 'context' attribute is missing in your service '{$id}' definition"); } $definition->addMethodCall( 'addProvider', [$attributes['context'], $id, new Reference($id)] ); } } } }