<?php
namespace App\EventListener;
use App\Event\ApplicantEvent;
use App\Writer\SuccessFactorsWriter;
use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
class SuccessFactorsApplicantEventListener
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var FeatureManagerInterface
*/
private $featureManager;
/**
* @var SuccessFactorsWriter
*/
private $successFactorsWriter;
public function __construct(
EntityManagerInterface $entityManager,
FeatureManagerInterface $featureManager,
SuccessFactorsWriter $successFactorsWriter
) {
$this->entityManager = $entityManager;
$this->featureManager = $featureManager;
$this->successFactorsWriter = $successFactorsWriter;
}
public function applicantSubmit(ApplicantEvent $applicantEvent)
{
if (!$this->featureManager->isActive(FeatureFlagListener::FEATURE_SUCCESS_FACTORS_APPLICANT_SEND)) {
return;
}
$this->successFactorsWriter->createApplicant($applicantEvent->getApplicant());
}
}