Skip to content

Instantly share code, notes, and snippets.

@jmather
Forked from anonymous/LoginListener.php
Created March 31, 2011 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmather/896294 to your computer and use it in GitHub Desktop.
Save jmather/896294 to your computer and use it in GitHub Desktop.
protected $event = null;
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->event = $event;
$username = $this->getUsername();
$session = $this->getSession();
$this->setFlash($session, $username);
}
protected function getUsername()
{
return $this->event->getAuthenticationToken()->getUsername();
}
protected function getSession()
{
return $this->event->getRequest()->getSession();
}
public function setFlash($event, $username)
{
$session->setFlash('notice', "Welcome {$username}, you have successfully logged in.");
}
public function testOnSecurityInteractiveLogin()
{
$loginEvent = new LoginListener();
// Get a mock $event of type InteractiveLoginEvent
$loginEvent->onSecurityInteractiveLogin($event);
}
class LoginListenerStub extends LoginListener
{
protected username = null;
protected session = null;
public setUsername($username) { $this->username = $username; }
public setSession($session) { $this->session = $session; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment