k1low/property-enum

CakePHP 3 的基于属性的枚举插件

支持包维护!
k1LoW

安装数: 22,476

依赖关系: 0

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 5

开放问题: 3

类型:cakephp-plugin

v1.4.0 2019-03-29 16:45 UTC

This package is auto-updated.

Last update: 2024-08-29 04:14:35 UTC


README

此插件是 CakeDC/Enum 的 PropertyStrategy

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 包的推荐方法是

composer require k1low/property-enum

属性示例

class ArticlesTable extends Table
{
    public $enums = [
        'status' => [
            'public' = 'Published';
            'draft' = 'Drafted';
            'archive' = 'Archived';
        ],
    ];

    public function initialize(array $config)
    {
        $this->addBehavior('PropertyEnum.Enum', ['lists' => [
            'status' => [
                'strategy' => 'property',
            ]
        ]]);
    }
}

对于 CakePHP 2

请参阅 https://github.com/k1LoW/Enumm