doctrine / DoctrineORMModule

Doctrine ORM Module for Laminas
https://www.doctrine-project.org/projects/doctrine-orm-module.html
MIT License
437 stars 229 forks source link

How to register custom Hydration strategies? #732

Open MatthiasKuehneEllerhold opened 1 year ago

MatthiasKuehneEllerhold commented 1 year ago

I'd like to use php8.1 built in enums in doctrine backed entities. According to https://www.doctrine-project.org/projects/doctrine-laminas-hydrator/en/3.3/enum-strategy.html#using-enums-with-php-8-1 I need to create and register a custom hydration strategy for each enum I want to use.

Is there any configuration key where I can easily register them or do I have to use a Delegator on the DoctrineHydrator?

driehle commented 1 year ago

No, there is no specific configuration key, as currently there is no way to have hydrators being automatically created by DoctrineORMModule. Note that the hydrators are entity-specific anyways, as the properties for which you are registering the strategies will differ between different entities.