Skip to content

Commit

Permalink
OP-372 - ShippingExportEventListener - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkalon committed Jul 26, 2024
1 parent e401d70 commit ad10ff8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/EventListener/ShippingExportEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -83,19 +85,17 @@ 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',
$shipment->getOrder()->getNumber(),
$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);
}

Expand Down

0 comments on commit ad10ff8

Please sign in to comment.