diff --git a/Config/config.xml b/Config/config.xml
index b71bbfa..f20c3ba 100755
--- a/Config/config.xml
+++ b/Config/config.xml
@@ -37,6 +37,7 @@
+
diff --git a/Listener/APIListener.php b/Listener/APIListener.php
index c9c8bbb..1467ab5 100644
--- a/Listener/APIListener.php
+++ b/Listener/APIListener.php
@@ -3,7 +3,6 @@
namespace ColissimoPickupPoint\Listener;
-
use ColissimoPickupPoint\ColissimoPickupPoint;
use ColissimoPickupPoint\WebService\FindByAddress;
use OpenApi\Events\DeliveryModuleOptionEvent;
@@ -26,14 +25,19 @@ class APIListener implements EventSubscriberInterface
/** @var ContainerInterface */
protected $container;
+ /** @var ImageService */
+ protected $imageService;
+
/**
* APIListener constructor.
* @param ContainerInterface $container We need the container because we use a service from another module
* which is not mandatory, and using its service without it being installed will crash
+ * @param ImageService $imageService
*/
- public function __construct(ContainerInterface $container)
+ public function __construct(ContainerInterface $container, ImageService $imageService)
{
$this->container = $container;
+ $this->imageService = $imageService;
}
/**
@@ -209,13 +213,24 @@ public function getDeliveryModuleOptions(DeliveryModuleOptionEvent $deliveryModu
$minimumDeliveryDate = ''; // TODO (calculate delivery date from day of order)
$maximumDeliveryDate = ''; // TODO (calculate delivery date from day of order
+ $image = null;
+ $imageQuery = ModuleImageQuery::create()->findByModuleId($deliveryModuleOptionEvent->getModule()->getId())->getFirst();
+
+ if (null !== $imageQuery) {
+ try {
+ $image = $this->imageService->getImageUrl($imageQuery, 'module');
+ } catch (\Exception $e) {
+ Tlog::getInstance()->addError($e);
+ }
+ }
+
/** @var DeliveryModuleOption $deliveryModuleOption */
$deliveryModuleOption = ($this->container->get('open_api.model.factory'))->buildModel('DeliveryModuleOption');
$deliveryModuleOption
->setCode('ColissimoPickupPoint')
->setValid($isValid)
->setTitle('Colissimo Pickup Point')
- ->setImage('')
+ ->setImage($image)
->setMinimumDeliveryDate($minimumDeliveryDate)
->setMaximumDeliveryDate($maximumDeliveryDate)
->setPostage($postage)
@@ -241,4 +256,4 @@ public static function getSubscribedEvents()
return $listenedEvents;
}
-}
\ No newline at end of file
+}