33 lines
665 B
PHP
33 lines
665 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\UserBundle\EventSubscriber;
|
|
|
|
use KupShop\OrderingBundle\Cart;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
|
|
|
class LogoutSubscriber implements EventSubscriberInterface
|
|
{
|
|
public function __construct(
|
|
private Cart $cart,
|
|
) {
|
|
}
|
|
|
|
public static function getSubscribedEvents(): array
|
|
{
|
|
return [
|
|
LogoutEvent::class => [
|
|
['onLogout', 200],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function onLogout(): void
|
|
{
|
|
// Notify cart
|
|
$this->cart->userLoggedOut();
|
|
}
|
|
}
|