custom/plugins/MegasolBase/src/Subscriber/CheckLoginSubscriber.php line 24

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Megasol\MegasolBase\Subscriber;
  3. use Megasol\MegasolBase\Struct\MyCustomStruct;
  4. use Shopware\Core\Checkout\Customer\CustomerEntity;
  5. use Shopware\Core\Checkout\Customer\CustomerEvents;
  6. use Shopware\Core\Content\Product\ProductEntity;
  7. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  8. use Shopware\Core\System\User\UserEvents;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Shopware\Core\Content\Product\ProductEvents;
  11. class CheckLoginSubscriber implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         // Return the events to listen to as array like this:  <event to listen to> => <method to execute>
  16.         return [
  17.             CustomerEvents::CUSTOMER_LOADED_EVENT => 'onCustomerLogin'
  18.         ];
  19.     }
  20.     public function onCustomerLogin(EntityLoadedEvent $event): void
  21.     {
  22.         /** @var CustomerEntity $customerEntity */
  23.         /*foreach ($event->getEntities() as $customerEntity) {
  24.             //$customerEntity->addExtension('msag_construct', new MyCustomStruct());
  25.             dump($customerEntity->getId());
  26.         }
  27.         */
  28.     }
  29. }