Created
February 21, 2019 08:44
-
-
Save chihiro-adachi/1d98c5b49a7848e3d03251dcf6b7d02c to your computer and use it in GitHub Desktop.
イベントリスナ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Eccube\EventListener; | |
use Eccube\Entity\Customer; | |
use Eccube\Request\Context; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\HttpKernel\KernelEvents; | |
class LoginEventListeiner implements EventSubscriberInterface | |
{ | |
/** | |
* @var Context | |
*/ | |
private $context; | |
public function __construct(Context $context) | |
{ | |
$this->context = $context; | |
} | |
public function onPasswordChange(GetResponseEvent $event) | |
{ | |
if ($event->isMasterRequest()) { | |
$Customer = $this->context->getCurrentUser(); | |
if ($Customer instanceof Customer) { | |
// パスワードの有効期限をチェック後、切れていたらパスワード変更画面へリダイレクト | |
$event->setResponse(new RedirectResponse('/change_password')); | |
} | |
} | |
} | |
public static function getSubscribedEvents() | |
{ | |
return [ | |
KernelEvents::REQUEST => 'onPasswordChange', | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment