コード例 #1
0
 /**
  * Check if the user is allowed to reach the step.
  *
  * @param  ModelInterface        $model
  * @param  Step                  $step
  * @throws AccessDeniedException
  */
 protected function checkCredentials(ModelInterface $model, Step $step)
 {
     $roles = $step->getRoles();
     if (!empty($roles) && !$this->authorizationChecker->isGranted($roles, $model->getWorkflowObject())) {
         throw new AccessDeniedException($step->getName());
     }
 }
コード例 #2
0
 /**
  * Create a new model state.
  *
  * @param  ModelInterface                                 $model
  * @param  string                                         $processName
  * @param  string                                         $stepName
  * @param  ModelState                                     $previous
  * @return \Lexik\Bundle\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());
     if ($previous instanceof ModelState) {
         $modelState->setPrevious($previous);
     }
     return $modelState;
 }