lamoda/enum-bundle

PHP-enum 的实用包装器

安装次数: 1,608

依赖项: 0

建议者: 0

安全: 0

星标: 11

关注者: 31

分支: 2

公开问题: 0

类型:symfony-bundle

1.6 2024-02-15 10:59 UTC

This package is auto-updated.

Last update: 2024-09-15 12:22:03 UTC


README

PHP-enum (https://github.com/paillechat/php-enum) 的实用包装器

安装

使用非常简单

composer require lamoda/enum-bundle:^1.0
// Kernel

public function registerBundles()
{
    // ...
    $bundles[] = new \Lamoda\EnumBundle\LamodaEnumBundle();
    // ...
}
# config.yml
lamoda_enum:
    dbal_types:
        # short example
        my_domain_enum: My\Domain\Enum
        # full example
        my_domain_enum_2: 
          class: My\Domain\Enum
          # identical strategy saves enum as its name as is, no conversion
          # lowercase strategy converts enum name to lowercase and vice versa on fetch
          strategy: identical    
class MyEntity
{
    /** @ORM\Column(type="my_domain_enum") */
    private $value;
}

这将启用将枚举的值字段转换为其他类型