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

beforeEnterStatus() public static method

Create name for a *before enter status* event.
public static beforeEnterStatus ( string $status = self::ANY_STATUS ) : string
$status string the status name or any status if not set
return string name of the event
    public static function beforeEnterStatus($status = self::ANY_STATUS)
    {
        self::_checkNonEmptyString('status', $status);
        return 'beforeEnterStatus{' . $status . '}';
    }

Usage Example

 public function testReturnReportWithEventsOnEnterWorkflow()
 {
     $model = new Item04();
     $model->on(WorkflowEvent::beforeEnterStatus('Item04Workflow/A'), function ($event) {
         $event->invalidate('my error message');
     });
     $report = $model->getNextStatuses(false, true);
     $this->assertCount(1, $report);
     $this->assertArrayHasKey('Item04Workflow/A', $report);
     $this->assertInstanceOf('raoul2000\\workflow\\base\\Status', $report['Item04Workflow/A']['status']);
     $this->assertCount(3, $report['Item04Workflow/A']['event']);
     $this->assertEquals([0 => ['name' => SimpleWorkflowBehavior::EVENT_BEFORE_CHANGE_STATUS, 'success' => null], 1 => ['name' => 'beforeEnterWorkflow{Item04Workflow}', 'success' => null], 2 => ['name' => 'beforeEnterStatus{Item04Workflow/A}', 'success' => false, 'messages' => [0 => 'my error message']]], $report['Item04Workflow/A']['event']);
     $this->assertEquals(false, $report['Item04Workflow/A']['isValid']);
 }
All Usage Examples Of raoul2000\workflow\events\WorkflowEvent::beforeEnterStatus