-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathInteractiveLoginSubscriber.php
More file actions
35 lines (29 loc) · 1.03 KB
/
InteractiveLoginSubscriber.php
File metadata and controls
35 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php declare(strict_types=1);
namespace App\EventSubscriber;
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Core\MVC\Symfony\Event\InteractiveLoginEvent;
use Ibexa\Core\MVC\Symfony\MVCEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class InteractiveLoginSubscriber implements EventSubscriberInterface
{
/**
* @var \Ibexa\Contracts\Core\Repository\UserService
*/
private $userService;
public function __construct(UserService $userService)
{
$this->userService = $userService;
}
public static function getSubscribedEvents()
{
return [
MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
];
}
public function onInteractiveLogin(InteractiveLoginEvent $event): void
{
// This loads a generic User and assigns it back to the event.
// You may want to create Users here, or even load predefined Users depending on your own rules.
$event->setApiUser($this->userService->loadUserByLogin('generic_user'));
}
}