<?php
namespace App\EventListener;
use App\Event\ApplicantEvent;
use App\Util\EasyFlexUtil;
use Flagception\Manager\FeatureManagerInterface;
class EasyFlexApplicantEventListener
{
private FeatureManagerInterface $featureManager;
private EasyFlexUtil $easyFlex;
/**
* EasyFlexApplicantEventListener constructor.
*/
public function __construct(
FeatureManagerInterface $featureManager,
EasyFlexUtil $easyFlex
) {
$this->featureManager = $featureManager;
$this->easyFlex = $easyFlex;
}
/**
* @throws \Exception
*/
public function applicantSubmit(ApplicantEvent $applicantEvent)
{
if (!$this->featureManager->isActive(FeatureFlagListener::FEATURE_EASYFLEX)) {
return;
}
$applicant = $applicantEvent->getApplicant();
$file = null;
if (!empty($applicantEvent->getForm()['CVFile'])) {
$file = $applicantEvent->getForm()['CVFile']->getData();
}
$this->easyFlex->postApplicant($applicant, $file);
}
}