/** * Returns the state message. * * @param ModelState $state * @return string */ public function getStateMessage(ModelState $state) { $message = ''; if ($state->getSuccessful()) { $data = $state->getData(); $message = isset($data['success_message']) ? $data['success_message'] : ''; } else { $message = implode("\n", $state->getErrors()); } return $message; }
protected function createData() { $model1 = new ModelState(); $model1->setWorkflowIdentifier('a1b2c3'); $model1->setCreatedAt(new \DateTime('2012-02-12')); $model1->setProcessName('process_1'); $model1->setStepName('step_A'); $model1->setSuccessful(true); $this->em->persist($model1); $model2 = new ModelState(); $model2->setWorkflowIdentifier('a1b2c3'); $model2->setCreatedAt(new \DateTime('2012-02-14')); $model2->setProcessName('process_1'); $model2->setStepName('step_B'); $model2->setSuccessful(true); $this->em->persist($model2); $model3 = new ModelState(); $model3->setWorkflowIdentifier('a1b2c3'); $model3->setCreatedAt(new \DateTime('2012-02-20')); $model3->setProcessName('process_1'); $model3->setStepName('step_C'); $model3->setSuccessful(false); $this->em->persist($model3); $model4 = new ModelState(); $model4->setWorkflowIdentifier('a1b2c3'); $model4->setCreatedAt(new \DateTime('2012-02-20')); $model4->setProcessName('process_2'); $model4->setStepName('step_A'); $model4->setSuccessful(false); $this->em->persist($model4); $this->em->flush(); }
/** * Add next * * @param ModelState $state */ public function addNext(ModelState $state) { $state->setPrevious($this); $this->next[] = $state; }
/** * Create a new model state. * * @param ModelInterface $model * @param string $processName * @param string $stepName * @param ModelState $previous * @return \Vas24x7\WorkflowBundle\Entity\ModelState */ protected function createModelState(ModelInterface $model, $processName, $stepName, $previous = null) { $modelState = new ModelState(); $modelState->setWorkflowIdentifier($model->getWorkflowIdentifier()); $modelState->setProcessName($processName); $modelState->setStepName($stepName); $modelState->setData($model->getWorkflowData()); $modelState->setCreatedBy($this->tokenStorage->getToken()->getUsername()); if ($previous instanceof ModelState) { $modelState->setPrevious($previous); } return $modelState; }