Feat: Implement workflow for disposition document uploads

This commit is contained in:
Björn Fromme
2023-10-13 11:52:32 +02:00
parent 6df725edc4
commit 8dcfa2f43c
7 changed files with 296 additions and 81 deletions
@@ -11,6 +11,7 @@ use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@@ -24,7 +25,8 @@ class DetailController extends AbstractController
public function __construct(
private readonly UploadHandler $uploadHandler,
private readonly EntityManagerInterface $entityManager,
private readonly WorkflowInterface $dispositionStateMachine,
#[Target('disposition')]
private readonly WorkflowInterface $workflow,
private readonly LoggerInterface $logger
) {
}
@@ -41,10 +43,10 @@ class DetailController extends AbstractController
$uploadSession = $this->uploadHandler->getUploadSession();
if (0 < $uploadSession->getCount()) {
if (true === $this->dispositionStateMachine->can($disposition, 'upload_contract')) {
if (true === $this->workflow->can($disposition, 'upload_contract')) {
$this->uploadContract($disposition, $uploadSession);
}
if (true === $this->dispositionStateMachine->can($disposition, 'upload_invoice')) {
if (true === $this->workflow->can($disposition, 'upload_invoice')) {
$this->uploadInvoice($disposition, $uploadSession);
}
}
@@ -74,7 +76,7 @@ class DetailController extends AbstractController
$upload->setStatus(Upload::STATUS_NEW);
$disposition->addDocument($upload);
$this->dispositionStateMachine->apply($disposition, 'upload_contract');
$this->workflow->apply($disposition, 'upload_contract');
$this->entityManager->flush();
@@ -101,7 +103,7 @@ class DetailController extends AbstractController
$upload->setStatus(Upload::STATUS_NEW);
$disposition->addDocument($upload);
$this->dispositionStateMachine->apply($disposition, 'upload_invoice');
$this->workflow->apply($disposition, 'upload_invoice');
$this->entityManager->flush();