I want to create custom events called user_logged
so that i can attach my listeners to those events.
I want to execute few functions whenever user has logged in.
I want to create custom events called user_logged
so that i can attach my listeners to those events.
I want to execute few functions whenever user has logged in.
This answer is little bit extend answer.
services.yml
AppBundle/EventSubscriber/HomePageEventSubscriber.php
AppBundle/Event/HomePageEvent.php
anywhere you wish, for example in home page controller
Create a class which extends
Symfony\Component\EventDispatcher\Event
.Then, use the event dispatcher service to dispatch the event:
You can register your event listener service like so: