[Serializer][XMLEncoder] add a way to Annotate/Attribute the ROOT_NODE_NAME on a Class
Description
add a new Annotation/Attribute to mark the XMLEncoder::ROOT_NODE_NAME on a class
Annotation\Context can't be used for this because that can't be tagged in classes (yet)
Example
/*
* @RootNodeName("product")
*/
class Product
{
public $name;
public $price;
}
results in:
<product>
<name></name>
<price></price>
</product>
probably fixed by this #51476
@xabbuh some more tests to this problem:
While
#[Context]can be used on Class now, that Context ist just not passed to the Encoder, only to the (de)normalizers etc., as far as I have debugged initially
and i don't know how to feed the Encoder with the Class Context yet
Just ran into the same issue while trying to transform some JMS Serializer-based code into Symfony Serializer-based code. This is indeed very cumbersome. I suppose the fact that the encoder does not use the classMetadataFactory while the object normalizers do has something to do with it. Maybe the context could refreshed by a specific XmlNormalizer whose job would be (possibly among others things) to set the XmlEncoder related context properties into the "live" context. But then the context would probably have to be passed by reference to all normalizers.