Feat: Add more workflow guards
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
namespace App\EventListener;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\Upload;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Workflow\Event\GuardEvent;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class DispositionWorkflowGuardSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
@@ -15,11 +16,28 @@ class DispositionWorkflowGuardSubscriber implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'workflow.disposition.guard.confirm_contract' => ['guardConfirmContract'],
|
||||
'workflow.disposition.guard.upload_contract' => ['guardUploadContract'],
|
||||
'workflow.disposition.guard.upload_invoice' => ['guardUploadInvoice'],
|
||||
'workflow.disposition.guard.confirm_invoice' => ['guardConfirmInvoice'],
|
||||
];
|
||||
}
|
||||
|
||||
public function guardConfirmContract(GuardEvent $event): void
|
||||
{
|
||||
/** @var Disposition $disposition */
|
||||
$disposition = $event->getSubject();
|
||||
$contractDocument = $disposition->getDocumentByType(Upload::TYPE_CONTRACT);
|
||||
|
||||
if (null === $contractDocument || Upload::STATUS_CHECKED !== $contractDocument->getStatus()) {
|
||||
$message = $this
|
||||
->translator
|
||||
->trans('message.confirm_contract.document_missing_or_not_checked')
|
||||
;
|
||||
$event->setBlocked(true, $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function guardUploadContract(GuardEvent $event): void
|
||||
{
|
||||
/** @var Disposition $disposition */
|
||||
@@ -75,4 +93,19 @@ class DispositionWorkflowGuardSubscriber implements EventSubscriberInterface
|
||||
$event->setBlocked(true, $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function guardConfirmInvoice(GuardEvent $event): void
|
||||
{
|
||||
/** @var Disposition $disposition */
|
||||
$disposition = $event->getSubject();
|
||||
$invoiceDocument = $disposition->getDocumentByType(Upload::TYPE_INVOICE);
|
||||
|
||||
if (null === $invoiceDocument || Upload::STATUS_CHECKED !== $invoiceDocument->getStatus()) {
|
||||
$message = $this
|
||||
->translator
|
||||
->trans('message.confirm_invoice.document_missing_or_not_checked')
|
||||
;
|
||||
$event->setBlocked(true, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,18 +23,22 @@ label:
|
||||
error: Fehler
|
||||
|
||||
message:
|
||||
confirm_contract:
|
||||
document_missing_or_not_checked: 'Der Honorarvertrag wurde noch nicht hochgeladen oder ist noch nicht geprüft worden.'
|
||||
upload_contract:
|
||||
too_late: 'Die Frist für den Upload des Honorarvertrages ist abgelaufen (%date_from% - %date_to%). Bitte wende dich an deinen Ansprechpartner'
|
||||
too_late: 'Die Frist für den Upload des Honorarvertrages ist abgelaufen (%date_from% - %date_to%). Bitte wende dich an deinen Ansprechpartner.'
|
||||
upload_invoice:
|
||||
too_early: 'Du kannst deine Honorarnote mit Beginn deines Einsatzes ab dem %date% einreichen.'
|
||||
too_late: 'Du hättest deine Honorarnote bis zum %date% einreichen müssen. Bitte wende dich an deinen Ansprechpartner.'
|
||||
confirm_invoice:
|
||||
document_missing_or_not_checked: 'Die Honorarnote wurde noch nicht hochgeladen oder ist noch nicht geprüft worden.'
|
||||
|
||||
uploader:
|
||||
drop_files: Dateien hier ablegen oder
|
||||
click_here: hier klicken
|
||||
file_too_big: Die maximale Dateigröße beträgt %maxFilesize%MB
|
||||
invalid_file_type: Der Dateityp ist nicht erlaubt
|
||||
max_files_exceeded: Die maximale Anzahl von Dateien is %maxFilesExceeded%
|
||||
drop_files: 'Dateien hier ablegen oder'
|
||||
click_here: 'hier klicken'
|
||||
file_too_big: 'Die maximale Dateigröße beträgt %maxFilesize%MB'
|
||||
invalid_file_type: 'Der Dateityp ist nicht erlaubt'
|
||||
max_files_exceeded: 'Die maximale Anzahl von Dateien is %maxFilesExceeded%'
|
||||
|
||||
paginator:
|
||||
previous: vorherige
|
||||
|
||||
Reference in New Issue
Block a user