src/EventListener/UserPropertyMailer.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Enum\PropertyUserStatusEnum;
  4. use App\Event\AppEvent;
  5. class UserPropertyMailer extends AbstractMailer
  6. {
  7.     /**
  8.      * {@inheritDoc}
  9.      */
  10.     public static function getSubscribedEvents()
  11.     {
  12.         return [
  13.             AppEvent::INVITE_TENANT => 'onTenantInvite',
  14.         ];
  15.     }
  16.     public function onTenantInvite(AppEvent $event)
  17.     {
  18.         $userProperty $event->getUserProperty();
  19.         $userProperty->setStatus(PropertyUserStatusEnum::INVITATION_SENT);
  20.         $userProperty->setInviteToken(base_convert(sha1(uniqid(mt_rand(), true)), 1636));
  21.         $this->em->persist($userProperty);
  22.         $this->em->flush();
  23.         $this->mailer->sendEventMail($eventAppEvent::INVITE_TENANT);
  24.     }
  25. }