beforeEnterWorkflow() public static method

Create name for a *before enter workflow* event.
public static beforeEnterWorkflow ( string $workflowId = self::ANY_WORKFLOW ) : string
$workflowId string the workflow id or any workflow id if not set
return string name of the event
 public function testOnEnterWorkflowError()
 {
     $this->model->on(WorkflowEvent::beforeEnterWorkflow('Item04Workflow'), function ($event) {
         $this->eventsBefore[] = $event;
         $event->isValid = false;
     });
     $this->model->on(WorkflowEvent::afterEnterWorkflow('Item04Workflow'), function ($event) {
         $this->eventsAfter[] = $event;
     });
     verify('event handler handlers have been called', count($this->eventsBefore) == 0 && count($this->eventsAfter) == 0)->true();
     $this->model->enterWorkflow();
     verify('current status is not set', $this->model->hasWorkflowStatus())->false();
     expect('beforeChangeStatus handler has been called', count($this->eventsBefore))->equals(1);
     expect('afterChangeStatus handler has not been called', count($this->eventsAfter))->equals(0);
 }
 /**
  * Produces the following event sequence when a model enters a workflow.
  *
  * - beforeEnterWorkflow(*)
  * - beforeEnterWorkflow(WID)
  * - beforeEnterStatus(*)
  * - beforeEnterStatus(ID)
  *
  * - afterEnterWorkflow(*)
  * - afterEnterWorkflow(WID)
  * - afterEnterStatus(*)
  * - afterEnterStatus(ID)
  *
  * Where WID is the workflow Id and ID is the status Id.
  *
  * @see \raoul2000\workflow\events\IEventSequence::createEnterWorkflowSequence()
  */
 public function createEnterWorkflowSequence($initalStatus, $sender)
 {
     return ['before' => [new WorkflowEvent(WorkflowEvent::beforeEnterWorkflow(), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::beforeEnterWorkflow($initalStatus->getWorkflowId()), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::beforeEnterStatus(), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::beforeEnterStatus($initalStatus->getId()), ['end' => $initalStatus, 'sender' => $sender])], 'after' => [new WorkflowEvent(WorkflowEvent::afterEnterWorkflow(), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::afterEnterWorkflow($initalStatus->getWorkflowId()), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::afterEnterStatus(), ['end' => $initalStatus, 'sender' => $sender]), new WorkflowEvent(WorkflowEvent::afterEnterStatus($initalStatus->getId()), ['end' => $initalStatus, 'sender' => $sender])]];
 }
 /**
  * Produces the following sequence when a model enters a workflow :
  *
  * - beforeEnterWorkflow(WID)
  * - afterEnterWorkflow(WID)
  *
  * @see \raoul2000\workflow\events\IEventSequence::createEnterWorkflowSequence()
  */
 public function createEnterWorkflowSequence($initalStatus, $sender)
 {
     $config = ['end' => $initalStatus, 'sender' => $sender];
     return ['before' => [new WorkflowEvent(WorkflowEvent::beforeEnterWorkflow($initalStatus->getWorkflowId()), $config)], 'after' => [new WorkflowEvent(WorkflowEvent::afterEnterWorkflow($initalStatus->getWorkflowId()), $config)]];
 }