<?php
namespace App\CIC\EventSubscriber;
use App\CIC\Service\cicApplyOnlineApiService;
use App\Event\Residence\BookingResidenceUpdatedEvent;
use App\Event\School\Student\StudentProfilePortalLoginChangeEvent;
use App\Message\Cic\StudentProfilePortalApplicantUpdateMessage;
use CIC\DB\envLoader\db;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class cicApplyOnlineStudentPortalChangeSchoolEventSubscriber implements EventSubscriberInterface
{
private ParameterBagInterface $params;
private $exporter;
private $sync = false;
private EntityManagerInterface $em;
private MessageBusInterface $bus;
/**
* DepartmentChangeSubscriber constructor.
*/
public function __construct(EntityManagerInterface $em, MessageBusInterface $bus)
{
$this->em = $em;
$this->bus = $bus;
}
public static function getSubscribedEvents()
{
return [
StudentProfilePortalLoginChangeEvent::class => [
['onChange'],
],
];
}
public function onChange(StudentProfilePortalLoginChangeEvent $event)
{
if($event->getStudent()->getStudentPortalUser()) {
$message = new StudentProfilePortalApplicantUpdateMessage($event->getStudent()->getStudentNumber());
$this->bus->dispatch($message);
}
return;
}
}