You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using the Serializer component for almost a year now on a client project, and we reached the point where we need to refactor some code, changing some classes name, but have data stored into database.
Question is: is it possible to create type aliases, for example, \App\Domain\Model\LegacyEntity that would map to \App\Domain\Model\EntityNewVersion ?
I looked at the class discriminator system, but it doesn't seem to have been created for this purpose. Properties can be aliased too (can it be done with something else than annotations by the way ? But that's another question).
I have a few use cases:
using the messenger component, we aliases all our message classes with semantic names (and not PHP classes) such as product.purchase for example, that would map to the \App\Domain\Event\PurchageProductMessage, this in order to have more meaningful reports for the client, but also in order to prepare the future where non-PHP applications might be plugged on the same message broker and publish or consume messages as well,
we have serialized data dangling around, either in import/export files or in database, often accompanied with the type alongside, which are still PHP classes names as of now, but the same we'd like to alias our entities.
In a development effort we are doing it by decorating multiple services from the messenger and serializer component, but that's an awful lot of code, and I'd love to know if the component gives us an opportunity to do it by configuration ?
Here's the code we have now to decorate the serializer https://gist.github.com/pounard/25d2a8d4502a6bb61e660957196a5773 (still in dev). It's within a custom bundle, which exposes the canonical type map and the aliases map in configuration, we do everything using YAML but never annotations.
Our name mapping serves two purposes:
we have a 1:1 mapping between a canonical alias and a PHP class (i.e. my_vendor.my_app.some_entity <-> \App\Entity\SomeEntity,
we have a 1:n mapping between a PHP class and its legacy aliases (for the product to continue working gracefully with outdated data after upgrade) where aliases can be either renamed or non existing PHP class names or arbitrary strings.
If there's not bundled solution for this problem, would you be OK with evaluating this idea and implementing it within the component ? I'd be glad to help one way or the other.
Thanks for your time.
The text was updated successfully, but these errors were encountered:
Hello,
We're using the Serializer component for almost a year now on a client project, and we reached the point where we need to refactor some code, changing some classes name, but have data stored into database.
Question is: is it possible to create type aliases, for example,
\App\Domain\Model\LegacyEntity
that would map to\App\Domain\Model\EntityNewVersion
?I looked at the class discriminator system, but it doesn't seem to have been created for this purpose. Properties can be aliased too (can it be done with something else than annotations by the way ? But that's another question).
I have a few use cases:
using the messenger component, we aliases all our message classes with semantic names (and not PHP classes) such as
product.purchase
for example, that would map to the\App\Domain\Event\PurchageProductMessage
, this in order to have more meaningful reports for the client, but also in order to prepare the future where non-PHP applications might be plugged on the same message broker and publish or consume messages as well,we have serialized data dangling around, either in import/export files or in database, often accompanied with the type alongside, which are still PHP classes names as of now, but the same we'd like to alias our entities.
In a development effort we are doing it by decorating multiple services from the messenger and serializer component, but that's an awful lot of code, and I'd love to know if the component gives us an opportunity to do it by configuration ?
Here's the code we have now to decorate the serializer https://gist.github.com/pounard/25d2a8d4502a6bb61e660957196a5773 (still in dev). It's within a custom bundle, which exposes the canonical type map and the aliases map in configuration, we do everything using YAML but never annotations.
Our name mapping serves two purposes:
my_vendor.my_app.some_entity
<->\App\Entity\SomeEntity
,If there's not bundled solution for this problem, would you be OK with evaluating this idea and implementing it within the component ? I'd be glad to help one way or the other.
Thanks for your time.
The text was updated successfully, but these errors were encountered: