phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Allow for auto register Types

Open bigfoot90 opened this issue 3 years ago • 5 comments

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.

bigfoot90 avatar Nov 08 '20 02:11 bigfoot90

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.

ostrolucky avatar Nov 08 '20 14:11 ostrolucky

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

bigfoot90 avatar Nov 12 '20 00:11 bigfoot90

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.

ostrolucky avatar Nov 12 '20 08:11 ostrolucky

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

ste93cry avatar Jan 25 '21 17:01 ste93cry

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

kbond avatar Jul 20 '22 23:07 kbond