时间:2021-07-01 10:21:17 帮助过:42人阅读
解决方法:
随便写的,仅供参考
<?php class process{ const STATE_1 = 1; const STATE_2 = 2; const STATE_3 = 3; const STATE_4 = 4; const STATE_5 = 5; const STATE_ALL = 99; private $state = null; private $statesLog = []; public function setState($state) { if (!$this->checkRoute($state)) { return false; } $this->state = $state; return true; } protected function routes() { return [ static::STATE_1=>[ 'id' =>static::STATE_1, 'name' =>'状态1', 'desc' =>'状态1的描述', 'to' =>[static::STATE_3, static::STATE_4], 'actions' =>[Actions::AC1, Actions::AC3], 'hooks' =>[...], ] ... ]; } } class Actions{ const AC1 = 1; const AC2 = 2; const AC3 = 3; public static function actions() { return [ static::AC1 =>[ 'id' =>static::AC1, 'name' =>'AC1', 'action'=>[ 'do' =>['nameSpace', 'className', 'methodName'], 'route' =>'/tools/sms/push', 'attr' =>['class'=>'hight_light warning'], ], ] ... ]; } public static function getAction($actionId) { $actions = static::actions(); return $actions[$actionId] ?? null; } }
可以看看php协程实现多任务协作,Generator,看看对你是否有帮助
相关文章:
PHP 工作流 自定义表单解决方案
介绍一个真正符合中国国情的工作流设计参考(包括PHP实现)
通达OA2015版工作流插件和列表控件数据解析