From ad10ff848c11bef99577d0da91e818e6e5aa8ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 26 Jul 2024 08:36:21 +0200 Subject: [PATCH] OP-372 - ShippingExportEventListener - refactoring --- src/EventListener/ShippingExportEventListener.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EventListener/ShippingExportEventListener.php b/src/EventListener/ShippingExportEventListener.php index 9ee3175..2fffffa 100644 --- a/src/EventListener/ShippingExportEventListener.php +++ b/src/EventListener/ShippingExportEventListener.php @@ -72,6 +72,8 @@ public function exportShipment(ResourceControllerEvent $event): void return; } + $flashBag = $this->requestStack->getSession()->getBag('flashes'); + try { $this->webClient->setShippingGateway($shippingGateway); $this->webClient->setShipment($shipment); @@ -83,7 +85,7 @@ public function exportShipment(ResourceControllerEvent $event): void $this->saveShippingLabel($shippingExport, $labelContent, 'pdf'); } catch (SoapFault $exception) { - $this->requestStack->getSession()->getBag('flashes')->add( + $flashBag->add( 'error', sprintf( 'Poczta Polska Web Service for #%s order: %s', @@ -91,11 +93,9 @@ public function exportShipment(ResourceControllerEvent $event): void $exception->getMessage(), ), ); - return; } - - $this->requestStack->getSession()->getBag('flashes')->add('success', 'bitbag.ui.shipment_data_has_been_exported'); + $flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); $this->markShipmentAsExported($shippingExport); }