they not call the subscribe Event "CUSTOMER_REGISTER_EVENT". I dont know what i make wrong. PHP:
public static function getSubscribedEvents(): array
{
return [
CustomerEvents::CUSTOMER_REGISTER_EVENT => 'onRegistration',
CustomerEvents::CUSTOMER_WRITTEN_EVENT => 'onCustomerGroupWritten',
ProductEvents::PRODUCT_LOADED_EVENT => 'onProductsLoaded'
];
}
public function onRegistration(EntityLoadedEvent $event)
{
$this->logger->info('ON REGISTER');
}
My services.xml:
<services>
<service id="RegisterChangeClass\Listener\RegisterListener">
<argument type="service" id="logger" />
<argument type="service" id="customer.repository" />
<argument type="service" id="router.request_context" />
<tag name="kernel.event_subscriber" />
</service>
</services>
All other events works without problems. Does anyone have any ideas?
Thanks and regards
Does this work for you ?
public static function getSubscribedEvents()
{
return [
GuestCustomerRegisterEvent::class => 'onRegisterGuest',
CustomerRegisterEvent::class => 'onRegister'
];
}
public function onRegister(CustomerRegisterEvent $event)
{
$this->logger->info("Customer register", ["id" => $event->getCustomerId()]);
}
public function onRegisterGuest(GuestCustomerRegisterEvent $event)
{
$this->logger->info("Guest customer", ["id" => $event->getCustomerId()]);
}
The issue seems to be that the CustomerRegisterEvent is not dispatched with the event name, so it will then use the class as the event name.