vendor/launchpad/backend/src/Base/EventSubscriber/Kyc/KycEventSubscriber.php line 50

Open in your IDE?
  1. <?php
  2. namespace LaunchPad\Bundle\LaunchPadBundle\Base\EventSubscriber\Kyc;
  3. use LaunchPad\Bundle\LaunchPadBundle\Admin\Service\UserAdminService;
  4. use LaunchPad\Bundle\LaunchPadBundle\Base\Entity\KYC\KycProcess;
  5. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\Notifications\NotificationTypes\KYC\KycSuccessfulNotification;
  6. use Psr\Container\ContainerInterface;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\EventDispatcher\GenericEvent;
  9. class KycEventSubscriber implements EventSubscriberInterface
  10. {
  11.     /** @var ContainerInterface */
  12.     private $container;
  13.     /**
  14.      * KycEventSubscriber constructor.
  15.      * @param ContainerInterface $container
  16.      */
  17.     public function __construct(ContainerInterface $container)
  18.     {
  19.         $this->container $container;
  20.     }
  21.     const KYC_DOCUMENT_REQUESTED 'kyc.document.requested';
  22.     const KYC_ACCEPTED 'kyc.accepted';
  23.     const KYC_REJECTED 'kyc.rejected';
  24.     /**
  25.      * Get subscribed events
  26.      *
  27.      * @return array
  28.      */
  29.     public static function getSubscribedEvents()
  30.     {
  31.         return array(
  32.             UserAdminService::EVENT_USER_CREATED    => 'userCreated',
  33.             self::KYC_DOCUMENT_REQUESTED    => 'documentRequested',
  34.             self::KYC_ACCEPTED              => 'kycAccepted',
  35.             self::KYC_REJECTED              => 'kycRejected',
  36.         );
  37.     }
  38.     /**
  39.      * Document requested
  40.      *
  41.      * @param GenericEvent $event
  42.      */
  43.     public function documentRequested(GenericEvent $event)
  44.     {
  45.     }
  46.     /**
  47.      * Called when new user is created
  48.      *
  49.      * @param GenericEvent $event
  50.      */
  51.     public function userCreated(GenericEvent $event)
  52.     {
  53.         $this->container->get('lp.kyc')->handleNewUser($event->getSubject());
  54.     }
  55.     /**
  56.      * KYC accepted
  57.      *
  58.      * @param GenericEvent $event
  59.      * @throws \Exception
  60.      */
  61.     public function kycAccepted(GenericEvent $event)
  62.     {
  63.         /** @var KycProcess $process */
  64.         $process $event->getSubject();
  65.         if($process->getOrigin() == KycProcess::KYC_ORIGIN_REGISTRATION) {
  66.             $this->container->get('lp.account')->userKYCed($process->getUser());
  67.             $this->container->get('lp.notifications')->push($process->getUser(), new KycSuccessfulNotification($process));
  68.         }
  69.     }
  70.     /**
  71.      * KYC rejected
  72.      *
  73.      * @param GenericEvent $event
  74.      */
  75.     public function kycRejected(GenericEvent $event)
  76.     {
  77.     }
  78. }