is backed by basecom. As a professional software service provider, basecom implements customized solutions in the areas of e-commerce, PIM solutions and web portals. With our experience and certified expertise, we have been one of the most renowned Symfony specialists in Germany for many years.
Contributed by
Mathias Arlaud
in #43973.
The Serializer component allows you to pass some context information to the
serializing and deserializing process. For example, to ignore certain attributes
when serializing, you can use the following code:
In Symfony 6.1 we’re improving the definition of serialization contexts with the
introduction of Context Builders. Instead of having to deal with plain arrays,
these objects allow you to define the context using a fluent interface which
provides autocompletion, validation and documentation.
As shown in this example, you can mix both arrays and builder objects and you
can even merge these context objects between them:
If you need the context as a plain array (e.g. to pass it to serialize()
method) call to the toArray()
method:
When building your own context builder, consider using the
Symfony
to reuse some
common methods: