Reputation: 617
I'm using Doctrine 2 in a Symfony 2 environment.
I've created a custom data type which extends \Doctrine\DBAL\Types\Type. This data type should map an integer value stored in database to a specific string (like ENUM, but integer and string must be accessible).
At the moment the mapping of these values is hardcoded within the doctrine type using a class variable which holds and array.
class xyType extends \Doctrine\DBAL\Types\Type {
public static $messageTypes = array(
10 => "Wareneingang",
20 => "Polstern",
.
.
.
}
.
.
}
Now I want to put this array into the config.yml of this bundle. But I don't know how to use Dependency Injection in this type class, to be able to access my config parameters in any way...
I hope you can help me. I'm also open for other ideas to implement this.
Thx in advance
Upvotes: 0
Views: 858
Reputation: 4860
Yes, you cannot access DI in your type class, but there is bundle initialization stage where you can save your types from config to your static property. So i suggest using YourBundleExtension to solve this.
Upvotes: 1