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