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); }