<?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 cicLegacyTrackerStudentPortalChangeSchoolEventSubscriber implements EventSubscriberInterface
{
private ParameterBagInterface $params;
private $exporter;
private $sync = false;
private EntityManagerInterface $em;
private MessageBusInterface $bus;
private db $db;
/**
* DepartmentChangeSubscriber constructor.
*/
public function __construct(db $db)
{
$this->db = $db;
}
public static function getSubscribedEvents()
{
return [
StudentProfilePortalLoginChangeEvent::class => [
['onChange'],
],
];
}
public function onChange(StudentProfilePortalLoginChangeEvent $event)
{
if($event->getStudent()->getStudentPortalUser()) {
//Update SINFO record
$this->db->update(
'cssc_mysql',
[
'E_RPT_ID'=>$event->getStudent()->getStudentPortalUser(),
'E_RPT_PW'=>$event->getStudent()->getStudentPortalKey(),
],
'uuid=?',
[
$event->getStudent()->getUuid()->toBase32()]
);
//Insert erepAccount Record
$date=new \DateTime();
$this->db->insert('erep_accounts',[
'usr'=>$event->getStudent()->getStudentPortalUser(),
'pass'=>md5($event->getStudent()->getStudentPortalKey()),
'dt'=>$date->format("Y-m-d H:i:s"),
'STATUS'=>'created'
]);
}
return;
}
}