<?php declare(strict_types=1);
namespace VioRepresentativeLogin\Storefront\Subscriber;
use Shopware\Core\Checkout\Customer\Event\CustomerRegisterEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use VioRepresentativeLogin\Core\Services\AgentService;
class RegisterEventSubscriber implements EventSubscriberInterface
{
private AgentService $agentService;
public function __construct(AgentService $agentService)
{
$this->agentService = $agentService;
}
public static function getSubscribedEvents(): array
{
return [
CustomerRegisterEvent::class => 'onCustomerRegister'
];
}
public function onCustomerRegister(CustomerRegisterEvent $event): void
{
$salesChannelContext = $event->getSalesChannelContext();
$this->agentService->assignCurrentCustomer($salesChannelContext);
}
}