コード例 #1
0
 /**
  * Convert state object to model representation.
  *
  * @param State $state The state being persisted.
  *
  * @return StateModel
  */
 private function convertStateToModel(State $state)
 {
     $model = new StateModel();
     $model->workflowName = $state->getWorkflowName();
     $model->entityId = (string) $state->getEntityId();
     $model->transitionName = $state->getTransitionName();
     $model->stepName = $state->getStepName();
     $model->success = $state->isSuccessful();
     $model->errors = $this->serialize($state->getErrors());
     $model->data = $this->serialize($state->getData());
     $model->reachedAt = $state->getReachedAt()->getTimestamp();
     $model->tstamp = time();
     return $model;
 }
コード例 #2
0
ファイル: ItemSpec.php プロジェクト: netzmacht/workflow
 function it_latest_state_from_history(EntityId $entityId, State $state, State $failedState)
 {
     $failedState->isSuccessful()->willReturn(false);
     $failedState->getStepName()->willReturn('failed');
     $state->isSuccessful()->willReturn(true);
     $state->getStepName()->willReturn('start');
     $state->getWorkflowName()->shouldBeCalled();
     $this->beConstructedThrough('reconstitute', array($entityId, static::$entity, array($state, $failedState)));
     $this->getLatestState(false)->shouldReturn($failedState);
 }
コード例 #3
0
ファイル: Item.php プロジェクト: netzmacht/workflow
 /**
  * Apply a new state.
  *
  * @param State $state The state being assigned.
  *
  * @return void
  */
 private function apply(State $state)
 {
     // only change current step if transition was successful
     if ($state->isSuccessful()) {
         $this->currentStepName = $state->getStepName();
         $this->workflowName = $state->getWorkflowName();
     } elseif (!$this->isWorkflowStarted()) {
         $this->workflowName = $state->getWorkflowName();
     }
     $this->stateHistory[] = $state;
 }