| 1 | <?php |
||
| 17 | trait ActionTrait |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array this property defines the a mapping for each action. |
||
| 21 | * For each action that should only support limited set of values |
||
| 22 | * you add a value with the action id as array key and an array value of |
||
| 23 | * allowed status codes (e.g. 'create' => 'value1', 'delete' => 'value2'). |
||
| 24 | * If an action is not defined the default action property will be used. |
||
| 25 | * |
||
| 26 | * You can use `'*'` to stand for all actions. When an action is explicitly |
||
| 27 | * specified, it takes precedence over the specification given by `'*'`. |
||
| 28 | * |
||
| 29 | * For example, |
||
| 30 | * |
||
| 31 | * ```php |
||
| 32 | * [ |
||
| 33 | * 'create' => 'value1', |
||
| 34 | * 'update' => 'value2', |
||
| 35 | * '*' => 'value3', |
||
| 36 | * ] |
||
| 37 | * ``` |
||
| 38 | */ |
||
| 39 | public $actions = []; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * The default action value |
||
| 43 | * |
||
| 44 | * @var bool |
||
| 45 | */ |
||
| 46 | public $default = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $action |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | protected function actionMatch(string $action): bool |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param string $action |
||
| 63 | * @return string|null |
||
| 64 | */ |
||
| 65 | protected function findAction(string $action) |
||
| 77 | } |
||
| 78 |