File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ # Doctrine Enum PHP Type
2+
3+ ---
4+
5+ ## Read the enum php doc:
6+
7+ > https://github.com/Neutron-Pro/enum-php
8+
9+ ---
10+
11+ ## Installation
12+
13+ ` composer require neutronstars/doctrine-enum-php-type `
14+
15+ ---
16+
17+ ## Doctrine Configuration
18+
19+ If you use it, you must create a Type class for your enum:
20+
21+ ``` php
22+ namespace App\Types;
23+
24+ class MyEnumType extends \NeutronStars\Enum\Types\EnumType {
25+ public const MY_ENUM = 'my_enum';
26+
27+ public function getName(): string
28+ {
29+ return self::MY_ENUM;
30+ }
31+
32+ public function convertToPHPValue($value,\Doctrine\DBAL\Platforms\AbstractPlatform $platform): MyEnum
33+ {
34+ return MyEnum::from($value);
35+ }
36+ }
37+ ```
38+
39+ And you must add this to the ` doctrine.yaml ` configuration file:
40+
41+ ``` yml
42+ doctrine :
43+ dbal :
44+ types :
45+ my_enum :
46+ class : App\Types\MyEnumType
47+ ` ` `
48+
49+ ---
You can’t perform that action at this time.
0 commit comments