In my symfony project I have created a command for cron task(runs one time for day). It change a table and that table has updatedBy property (by doctrine blameable listener). So i have to log a user programmatically. here is my code for that.
if ($this->container->get("security.context")->getToken() === null) {
$token = new UsernamePasswordToken($systemUser, null, "admin_area", $systemUser->getRoles());
$this->container->get("security.context")->setToken($token);
}
My problem is how to dispatch this event. Because there is no request I cant use following code.
$request = $this->container->get("request");
$event = new InteractiveLoginEvent($request, $token);
$this->container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
Also get("request") service cannot use inside command. Please help me to dispatch this event.