findTaggedServiceIds('jms_serializer.encoder') as $id => $attributes) { if (!isset($attributes[0]['format'])) { throw new RuntimeException(sprintf('"format" attribute must be specified for service "%s" and tag "jms_serializer.encoder".', $id)); } $encoders[$attributes[0]['format']] = $id; } foreach (array_keys($container->findTaggedServiceIds('jms_serializer.serializer')) as $id) { $container ->getDefinition($id) ->addArgument($encoders) ; } } }