raoul2000\workflow\base\SimpleWorkflowBehavior::getWorkflow PHP Method

getWorkflow() public method

Returns the current Workflow instance the model is in or NULL if the model is not in a workflow.
public getWorkflow ( ) : null | Workflow
return null | Workflow the workflow the owner model is currently in, or null if the owner model is not in a workflow
    public function getWorkflow()
    {
        return $this->hasWorkflowStatus() ? $this->getWorkflowSource()->getWorkflow($this->getWorkflowStatus()->getWorkflowId()) : null;
    }

Usage Example

Esempio n. 1
0
 /**
  * Returns the status string of the next valid status from the list of transitions
  *
  * @param BaseActiveRecord|SimpleWorkflowBehavior $model
  * @return string
  */
 public static function getNextStatus($model)
 {
     $currentStatus = $model->getAttribute('status');
     $statusList = $model->getWorkflowSource()->getAllStatuses($model->getWorkflow()->getId());
     $transitions = array_keys(WorkflowHelper::getNextStatusListData($this->owner));
     $started = false;
     foreach ($statusList as $status) {
         $status_id = $status->getId();
         if ($started) {
             if (in_array($status_id, $transitions) && static::isValidNextStatus($model, $status_id)) {
                 return $status_id;
             }
         }
         if ($status_id == $currentStatus) {
             $started = true;
         }
     }
     return $currentStatus;
 }