entity workflow: handle sending an access key by email

This commit is contained in:
2022-02-24 21:53:05 +01:00
parent ff1ff8f5bb
commit 1479e2ae9a
13 changed files with 188 additions and 40 deletions

View File

@@ -21,7 +21,6 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Chill\MainBundle\Workflow\Validator\StepDestValid;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -152,9 +151,6 @@ class WorkflowController extends AbstractController
throw new AccessDeniedException('Not a valid user');
}
dump($accessKey);
dump($entityWorkflowStep->getAccessKey());
if ($entityWorkflowStep->getAccessKey() !== $accessKey) {
throw new AccessDeniedException('Access key is invalid');
}
@@ -264,6 +260,7 @@ class WorkflowController extends AbstractController
}
$entityWorkflow->futureDestUsers = $transitionForm['future_dest_users']->getData();
$entityWorkflow->futureDestEmails = $transitionForm['future_dest_emails']->getData();
$workflow->apply($entityWorkflow, $transition);
@@ -271,18 +268,13 @@ class WorkflowController extends AbstractController
$entityWorkflow->getCurrentStep()->addDestUser($user);
}
$errors = $this->validator->validate(
$entityWorkflow->getCurrentStep(),
new StepDestValid()
);
if (count($errors) === 0) {
$this->entityManager->flush();
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
foreach ($transitionForm['future_dest_emails']->getData() as $email) {
$entityWorkflow->getCurrentStep()->addDestEmail($email);
}
return new Response((string) $errors, Response::HTTP_UNPROCESSABLE_ENTITY);
$this->entityManager->flush();
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
}
if ($transitionForm->isSubmitted() && !$transitionForm->isValid()) {