<?php
namespace App\EventListener;
use App\Event\ApplicantEvent;
use App\Util\BrixsUtil;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Flagception\Manager\FeatureManagerInterface;
class BrixsApplicantEventListener
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var FeatureManagerInterface
*/
private $featureManager;
/**
* @var BrixsUtil
*/
private $brixs;
/**
* BrixsApplicantEventListener constructor.
*/
public function __construct(
EntityManagerInterface $entityManager,
FeatureManagerInterface $featureManager,
BrixsUtil $brixs
) {
$this->entityManager = $entityManager;
$this->featureManager = $featureManager;
$this->brixs = $brixs;
}
/**
* @throws Exception
*/
public function applicantSubmit(ApplicantEvent $applicantEvent)
{
if (!$this->featureManager->isActive(FeatureFlagListener::FEATURE_BRIXS)) {
return;
}
$applicant = $applicantEvent->getApplicant();
$file = $applicantEvent->getForm()['CVFile']->getData();
$this->brixs->postApplicant($applicant, $file);
}
}