-
-
Notifications
You must be signed in to change notification settings - Fork 474
Open
Description
Feature Request
Copied from:
In order to have distinct types per EntityManager instance, the static methods of the Type class must move to a TypeRegistry service class. This design is inspired by the Doctrine\DBAL\Types\TypeRegistry class.
- Introduce the TypeRegistry
- Inject the TypeRegistry instance everywhere the static method of the Type class are used
- Make the constructor of Type public and non-final to allow injecting dependencies or configuration into the type instances
- A similar change has been discussed in Remove final constructor for Type dbal#6705 (review)
Use case
I want to create a custom type, that needs some services from the container.
final class JsonSerializableType extends JsonType
{
public function __construct(
private readonly DbalJsonTypeSerializer $serializer,
) {}
// ...
}Currently, I have to resort on a "ugly" boot() hack in the kernel, to use it:
public function boot() : void
{
parent::boot();
Type::getTypeRegistry()->register(
$name,
new JsonSerializableType($this->container->get(DbalJsonTypeSerializer::class)),
);
}Metadata
Metadata
Assignees
Labels
No labels