<?php
declare(strict_types=1);
namespace App\Module\Payment\Subscriber;
use App\Store\StoreContext;
use App\Module\ShortSimpleCheckout\Event\View\BaseViewEvent;
use App\Module\ShortSimpleCheckout\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* @author André Varelmann <andre.varelmann@bestit-online.de>
* @package App\Module\Payment\Subscriber
*/
class UnzerPaymentSubscriber implements EventSubscriberInterface
{
private StoreContext $storeContext;
/**
* @param StoreContext $storeContext
*/
public function __construct(StoreContext $storeContext)
{
$this->storeContext = $storeContext;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
Events::SHIPPING_PAYMENT_INDEX_DISPATCH => 'addPublicKeyToView'
];
}
/**
* @param BaseViewEvent $event
*
* @return void
*/
public function addPublicKeyToView(BaseViewEvent $event): void
{
$event->replaceVariable('unzerPublicKey', $this->storeContext->getUnzerPublicKey());
}
}