<?php
namespace Harmonizely\EventListener;
use Harmonizely\Service\Base\Crypt\Container;
use Harmonizely\Service\Base\Crypt\Contract\ICrypt;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class CryptContainerInitListener
{
/**
* @var ICrypt
*/
private ICrypt $crypt;
/**
* CryptContainerInitListener constructor.
*
* @param ICrypt $crypt
*/
public function __construct(ICrypt $crypt)
{
$this->crypt = $crypt;
}
/**
* On kernel request
*
* @param RequestEvent $event
*/
public function onKernelRequest(RequestEvent $event): void
{
$this->init();
}
/**
* On command request
*
* @param ConsoleCommandEvent $event
*/
public function onCommandRequest(ConsoleCommandEvent $event): void
{
$this->init();
}
private function init(): void
{
Container::init($this->crypt, Container::DOCTRINE_CRYPT);
}
}