doctrine / DoctrineBundle

Symfony Bundle for Doctrine ORM and DBAL
https://www.doctrine-project.org/projects/doctrine-bundle.html
MIT License
4.68k stars 448 forks source link

Allow for auto register Types #1246

Open bigfoot90 opened 3 years ago

bigfoot90 commented 3 years ago

With https://github.com/thunderer/Platenum we can use Enums in php, it also provide a Doctrine custom type witch maps to native ENUM mysql type.

I'm asking for the ability to automatically discovery and register custom types, as we are already doing for the entity mappings in our doctrine.yaml configuration files where we tell into which directories to look for.

ostrolucky commented 3 years ago

Difference here is that discovery of entities in a namespace is handled by ORM, bundle just passes it over.

Considering types are not services, more appropriate place to ask for this feature might be DBAL. But if anyone wants to give this a try here, I'm not against that.

bigfoot90 commented 3 years ago

U're right, I'm closing this for the moment.

ostrolucky commented 3 years ago

Actually, I was looking into this a bit and it should be possible to make types to be services. Then we would be able to tag these and inject everything tagged as such into dbal.

ste93cry commented 3 years ago

I absolutely would like to see types as tagged services, this would enable a whole world of things that are now not possible, e.g. injecting custom services into the type to re-use logic, etc. Also, if we could get rid of that static singleton object that is the types registry it would be even cooler

kbond commented 2 years ago

@ostrolucky, if types can be services, how could we allow arguments if Type::__construct() cannot be overriden?