From 2113e27bcbca5fbb68a727de7cf61e6c21e34a4e Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Mon, 14 Oct 2024 12:00:12 +0200 Subject: [PATCH] Added FormConfigStamp --- config/listeners.php | 1 + src/Config/ConfigLoader.php | 5 +++++ src/Config/FormConfig.php | 9 +++++++++ src/EventListener/ProcessFormDataListener.php | 9 +++++++++ src/Parcel/Stamp/FormConfigStamp.php | 20 +++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 src/Config/FormConfig.php create mode 100644 src/Parcel/Stamp/FormConfigStamp.php diff --git a/config/listeners.php b/config/listeners.php index 46a099b2..d09a0fdb 100644 --- a/config/listeners.php +++ b/config/listeners.php @@ -107,6 +107,7 @@ ->args([ service(NotificationCenter::class), service(FileUploadNormalizer::class), + service(ConfigLoader::class), ]) ; diff --git a/src/Config/ConfigLoader.php b/src/Config/ConfigLoader.php index 21771366..425f8eee 100644 --- a/src/Config/ConfigLoader.php +++ b/src/Config/ConfigLoader.php @@ -38,6 +38,11 @@ public function loadModule(int $id): ModuleConfig|null return $this->loadConfig($id, 'tl_module', ModuleConfig::class); } + public function loadForm(int $id): FormConfig|null + { + return $this->loadConfig($id, 'tl_form', FormConfig::class); + } + /** * @return array */ diff --git a/src/Config/FormConfig.php b/src/Config/FormConfig.php new file mode 100644 index 00000000..f8255f5d --- /dev/null +++ b/src/Config/FormConfig.php @@ -0,0 +1,9 @@ +with(new BulkyItemsStamp($bulkyItemVouchers)); } + $formConfig = $this->configLoader->loadForm((int) $form->id); + + if (null !== $formConfig) { + $stamps = $stamps->with(new FormConfigStamp($formConfig)); + } + $this->notificationCenter->sendNotificationWithStamps((int) $formData['nc_notification'], $stamps); } } diff --git a/src/Parcel/Stamp/FormConfigStamp.php b/src/Parcel/Stamp/FormConfigStamp.php new file mode 100644 index 00000000..c0fc06dc --- /dev/null +++ b/src/Parcel/Stamp/FormConfigStamp.php @@ -0,0 +1,20 @@ +formConfig); + } + + public static function fromArray(array $data): self + { + return new self(FormConfig::fromArray($data)); + } +}