src/Module/Payment/Subscriber/UnzerPaymentSubscriber.php line 43

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Module\Payment\Subscriber;
  4. use App\Store\StoreContext;
  5. use App\Module\ShortSimpleCheckout\Event\View\BaseViewEvent;
  6. use App\Module\ShortSimpleCheckout\Events;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9. * @author André Varelmann <andre.varelmann@bestit-online.de>
  10. * @package App\Module\Payment\Subscriber
  11. */
  12. class UnzerPaymentSubscriber implements EventSubscriberInterface
  13. {
  14. private StoreContext $storeContext;
  15. /**
  16. * @param StoreContext $storeContext
  17. */
  18. public function __construct(StoreContext $storeContext)
  19. {
  20. $this->storeContext = $storeContext;
  21. }
  22. /**
  23. * @return array
  24. */
  25. public static function getSubscribedEvents(): array
  26. {
  27. return [
  28. Events::SHIPPING_PAYMENT_INDEX_DISPATCH => 'addPublicKeyToView'
  29. ];
  30. }
  31. /**
  32. * @param BaseViewEvent $event
  33. *
  34. * @return void
  35. */
  36. public function addPublicKeyToView(BaseViewEvent $event): void
  37. {
  38. $event->replaceVariable('unzerPublicKey', $this->storeContext->getUnzerPublicKey());
  39. }
  40. }