/** * Checks if a given status is a valid transition from the current status * * @param BaseActiveRecord|SimpleWorkflowBehavior $model * @param string $status_id * @return bool */ public static function isValidNextStatus($model, $status_id) { $eventSequence = $model->getEventSequence($status_id); foreach ($eventSequence['before'] as $event) { if ($model->hasEventHandlers($event->name)) { $model->trigger($event->name, $event); if ($event->isValid === false) { return false; } } } return true; }