Feat: Implement workflow for disposition document uploads
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user