Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serializer][XMLEncoder] add a way to Annotate/Attribute the ROOT_NODE_NAME on a Class #51652

Open
Hanmac opened this issue Sep 14, 2023 · 3 comments

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Sep 14, 2023

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>
@Hanmac
Copy link
Contributor Author

Hanmac commented Sep 15, 2023

probably fixed by this #51476

@xabbuh xabbuh closed this as completed Sep 15, 2023
@Hanmac
Copy link
Contributor Author

Hanmac commented Jan 31, 2024

@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

@stof stof reopened this Feb 1, 2024
@rrajkomar
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants