<?php
namespace App\EventListener;
use App\Enum\PropertyUserStatusEnum;
use App\Event\AppEvent;
class UserPropertyMailer extends AbstractMailer
{
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
AppEvent::INVITE_TENANT => 'onTenantInvite',
];
}
public function onTenantInvite(AppEvent $event)
{
$userProperty = $event->getUserProperty();
$userProperty->setStatus(PropertyUserStatusEnum::INVITATION_SENT);
$userProperty->setInviteToken(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
$this->em->persist($userProperty);
$this->em->flush();
$this->mailer->sendEventMail($event, AppEvent::INVITE_TENANT);
}
}