/** * http://api.drupal.org/api/drupal/modules--user--user.api.php/function/hook_user_login/7 * * @param \Ekino\Bundle\DrupalBundle\Event\DrupalEvent $event * @return void */ public function onLogin(DrupalEvent $event) { $edit = $event->getParameter(0); $user = $event->getParameter(1); if (!$user instanceof UserInterface) { throw new \RuntimeException('An instance of UserInterface is expected'); } // The ContextListener from the Security component is hijacked to insert a valid token into session // so next time the user go to a valid symfony2 url with a proper security context, then the following token // will be used foreach ($this->providerKeys as $providerKey) { $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles()); $this->request->getSession()->set('_security_' . $providerKey, serialize($token)); } $this->request->getSession()->save(); }
public function testReference() { $value = array('name' => 'Foo'); $event = new DrupalEvent(); $event->addParameter($value); $v =& $event->getParameter(0); $v['name'] = 'Bar'; $this->assertEquals('Bar', $value['name']); $value['name'] = 'Foo'; $this->assertEquals('Foo', $v['name']); }