Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
senghe authored Apr 21, 2023
1 parent c1ee07d commit f945df6
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ bitbag_shipping_export_plugin:
### Adding shipping export configuration form
```php
<?php

declare(strict_types=1);

namespace App\Form\Type;

use Symfony\Component\Form\AbstractType;
Expand Down Expand Up @@ -132,19 +136,23 @@ services:
### Adding shipping export event listener
```php
<?php

declare(strict_types=1);

namespace App\EventListener;

use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface;
use Doctrine\Persistence\ObjectManager;
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Webmozart\Assert\Assert;

final class FrankMartinShippingExportEventListener
{
/** @var FlashBagInterface */
private $flashBag;
/** @var RequestStack */
private $requestStack;

/** @var Filesystem */
private $filesystem;
Expand All @@ -156,12 +164,12 @@ final class FrankMartinShippingExportEventListener
private $shippingLabelsPath;

public function __construct(
FlashBagInterface $flashBag,
RequestStack $requestStack,
Filesystem $filesystem,
ObjectManager $shippingExportManager,
string $shippingLabelsPath
) {
$this->flashBag = $flashBag;
$this->requestStack = $requestStack;
$this->filesystem = $filesystem;
$this->shippingExportManager = $shippingExportManager;
$this->shippingLabelsPath = $shippingLabelsPath;
Expand All @@ -180,13 +188,16 @@ final class FrankMartinShippingExportEventListener
return;
}

$session = $this->requestStack->getSession();
$flashBag = $session->getBag('flashes');

if (false) {
$this->flashBag->add('error', 'bitbag.ui.shipping_export_error'); // Add an error notification
$flashBag->add('error', 'bitbag.ui.shipping_export_error'); // Add an error notification

return;
}

$this->flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification
$flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification
$this->saveShippingLabel($shippingExport, 'Some label content received from external API', 'pdf'); // Save label
$this->markShipmentAsExported($shippingExport); // Mark shipment as "Exported"
}
Expand Down

0 comments on commit f945df6

Please sign in to comment.