Conversation
src/DependencyInjection/Compiler/RegisterAsDoctrineTypeAttributePass.php
Outdated
Show resolved
Hide resolved
src/DependencyInjection/Compiler/RegisterAsDoctrineTypeAttributePass.php
Outdated
Show resolved
Hide resolved
src/DependencyInjection/Compiler/RegisterAsDoctrineTypeAttributePass.php
Outdated
Show resolved
Hide resolved
src/DependencyInjection/Compiler/RegisterAsDoctrineTypeAttributePass.php
Outdated
Show resolved
Hide resolved
3304bbe to
8f59bd1
Compare
8d6c4f7 to
e26bfe1
Compare
e26bfe1 to
ea214eb
Compare
|
@stof is it ok for you? |
|
I think this PR belongs more into the symfony/doctrine-bridge and there is already a PR for this: symfony/symfony#63774 |
AFAIK, the bridge aims to do a bridge between a Symfony component and Doctrine, but this feature is not related to a Symfony component, so it should belongs to the bundle IMHO |
|
I’m not fully convinced this should live in the bundle. According to the Symfony docs, DoctrineBridge is meant to “provide integration for Doctrine with Symfony components”, while DoctrineBundle mainly handles configuration and wiring. This change feels more like integration logic (how Symfony registers and discovers Doctrine types) rather than something that should be driven by bundle configuration. We already keep things like Doctrine types and Symfony specific behavior in the Bridge, so moving the registration logic there would keep responsibilities more clearly separated and consistent with existing patterns. Otherwise we risk spreading behavior across both layers, which makes it harder to reason about and reuse outside of a full DoctrineBundle setup. |
I agree with that, but there is no component involved here
Types you mention are Symfony component related types (Uid, Clock,...) |
Description
This PR add a new AsDbalType attribute to automatically register the related class as a DBAL type.
Problem Solved
Currently, to register a custom DBAL type, it must be manually declared in the Doctrine configuration file:
This approach is verbose and requires the developer to manage configuration in addition to the type class itself.
Feature Added
The addition of the #[AsDbalType] attribute allows the application to automatically detect and register any class that uses this attribute.
Concrete Usage Example
Here is how you can register a custom type directly via the attribute, without touching the YAML configuration:
1. Creating the Custom Type
2. Usage in an Entity
You can then use this type directly in your entities:
Advantages
doctrine.yamlfor every new custom type.