raoul2000\workflow\events\WorkflowEvent::afterChangeStatus PHP Method

afterChangeStatus() public static method

Create name for a *after change status* event.
public static afterChangeStatus ( string $start, string $end ) : string
$start string ID of the status which is at the start of the transition (the status that is left)
$end string ID of the status which is at the end of the transition (the status that is reached)
return string name of the event
    public static function afterChangeStatus($start, $end)
    {
        self::_checkNonEmptyString('start', $start);
        self::_checkNonEmptyString('end', $end);
        return 'afterChangeStatusFrom{' . $start . '}to{' . $end . '}';
    }

Usage Example

 public function testChangeStatusEventOnSaveFails()
 {
     $this->model->on(WorkflowEvent::beforeChangeStatus('Item04Workflow/A', 'Item04Workflow/B'), function ($event) {
         $this->eventsBefore[] = $event;
         $event->isValid = false;
     });
     $this->model->on(WorkflowEvent::afterChangeStatus('Item04Workflow/A', 'Item04Workflow/B'), function ($event) {
         $this->eventsAfter[] = $event;
     });
     $this->model->enterWorkflow();
     verify('current status is set', $this->model->hasWorkflowStatus())->true();
     verify('event handlers have never been called', count($this->eventsBefore) == 0 && count($this->eventsAfter) == 0)->true();
     $this->model->status = 'Item04Workflow/B';
     verify('save fails', $this->model->save())->false();
     expect('model has not changed status', $this->model->getWorkflowStatus()->getId())->equals('Item04Workflow/A');
     expect('beforeChangeStatus handler has been called', count($this->eventsBefore))->equals(1);
     expect('afterChangeStatus handler has not been called', count($this->eventsAfter))->equals(0);
 }
All Usage Examples Of raoul2000\workflow\events\WorkflowEvent::afterChangeStatus