src/Service/App/Merchant/EventListener/UpdateCustomerStatListener.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Service\App\Merchant\EventListener;
  3. use App\Background\Data\CustomerStatData;
  4. use App\Core\BackgroundWork\Contract\IClient;
  5. use App\Service\App\Merchant\Event\UpdateCustomerStatEvent;
  6. class UpdateCustomerStatListener
  7. {
  8.     /**
  9.      * Background work client
  10.      *
  11.      * @var IClient
  12.      */
  13.     private IClient $backgroundWorkClient;
  14.     /**
  15.      * @param IClient $backgroundWorkClient
  16.      */
  17.     public function __construct(IClient $backgroundWorkClient)
  18.     {
  19.         $this->backgroundWorkClient $backgroundWorkClient;
  20.     }
  21.     /**
  22.      * Handle event
  23.      *
  24.      * @param UpdateCustomerStatEvent $event
  25.      * @return void
  26.      */
  27.     public function onUpdateStat(UpdateCustomerStatEvent $event): void
  28.     {
  29.         $this->backgroundWorkClient->add(
  30.             new CustomerStatData($event->getMerchant(), $event->getCustomerId())
  31.         );
  32.         $this->backgroundWorkClient->runJobs();
  33.     }
  34. }