k1low/stateful-enum
Composer 安装命令:
composer require k1low/stateful-enum
包简介
Simple stateful enum plugin for CakePHP 3
README 文档
README
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require k1low/stateful-enum
Usage
class BugsTable extends Table { const STATUS_UNASSIGNED = 'unassigned'; const STATUS_ASSIGNED = 'assigned'; const STATUS_RESOLVED = 'resolved'; const STATUS_CLOSED = 'closed'; public $transitions = [ 'status' => [ 'assign' => [ 'from' => self::STATUS_UNASSIGNED, 'to' => self::STATUS_ASSIGNED ], 'resolve' => [ [self::STATUS_ASSIGNED, self::STATUS_UNASSIGNED], // from self::STATUS_RESOLVED // to ], 'close' => [ [self::STATUS_ASSIGNED, self::STATUS_UNASSIGNED, self::STATUS_RESOLVED], self::STATUS_CLOSED ], ] ]; public function initialize(array $config) { $this->primaryKey('id'); $this->addBehavior('StatefulEnum.StatefulEnum'); } }
So, This plugin set build state rules automatically.
References
This plugin is inspired by https://github.com/amatsuda/stateful_enum
统计信息
- 总下载量: 2.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-06