Exemplo n.º 1
0
 /**
  * Check if a module is valid
  *
  * @param IsValidPaymentEvent $event
  */
 public function isValid(IsValidPaymentEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $module = $event->getModule();
     // dispatch event to target specific module
     $dispatcher->dispatch(TheliaEvents::getModuleEvent(TheliaEvents::MODULE_PAYMENT_IS_VALID, $module->getCode()), $event);
     if ($event->isPropagationStopped()) {
         return;
     }
     // call legacy module method
     $event->setValidModule($module->isValidPayment());
 }
Exemplo n.º 2
0
 /**
  * Get postage from module using the classical module functions
  *
  * @param DeliveryPostageEvent $event
  */
 public function getPostage(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $module = $event->getModule();
     // dispatch event to target specific module
     $dispatcher->dispatch(TheliaEvents::getModuleEvent(TheliaEvents::MODULE_DELIVERY_GET_POSTAGE, $module->getCode()), $event);
     if ($event->isPropagationStopped()) {
         return;
     }
     // call legacy module method
     $event->setValidModule($module->isValidDelivery($event->getCountry()));
     if ($event->isValidModule()) {
         $event->setPostage($module->getPostage($event->getCountry()));
     }
 }
Exemplo n.º 3
0
 /**
  * Check if a payment module manage stock on creation
  *
  * @param EventDispatcher $dispatcher
  * @param PaymentModuleInterface $module
  * @return bool if the module manage stock on creation, false otherwise
  */
 protected function isModuleManageStockOnCreation(EventDispatcherInterface $dispatcher, PaymentModuleInterface $module)
 {
     $event = new ManageStockOnCreationEvent($module);
     $dispatcher->dispatch(TheliaEvents::getModuleEvent(TheliaEvents::MODULE_PAYMENT_MANAGE_STOCK, $module->getCode()));
     return null !== $event->getManageStock() ? $event->getManageStock() : $module->manageStockOnCreation();
 }