コード例 #1
0
 /**
  * Tests WordpressEvent addParameter() method
  *
  * Should return correct parameters
  */
 public function testAddParameter()
 {
     $event = new WordpressEvent();
     $event->addParameter('my-other-value');
     $this->assertTrue($event->hasParameter(0), 'Should return true because one parameter was added');
     $this->assertFalse($event->hasParameter(1), 'Should return false because only one parameter was added');
     $this->assertEquals('my-other-value', $event->getParameter(0));
 }
コード例 #2
0
 /**
  * Wordpress user login hook method
  *
  * @param WordpressEvent $event
  *
  * @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_login
  */
 public function onLogin(WordpressEvent $event)
 {
     $wpUser = $event->getParameter('user');
     $user = $this->userManager->find($wpUser->data->ID);
     $user->setWordpressRoles($wpUser->roles);
     $token = new UsernamePasswordToken($user, $user->getPass(), $this->firewall, $user->getRoles());
     $this->tokenStorage->setToken($token);
     $this->session->set('_security_' . $this->firewall, serialize($token));
 }
コード例 #3
0
 /**
  * Wordpress user login hook method
  *
  * @param WordpressEvent $event
  *
  * @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_login
  */
 public function onLogin(WordpressEvent $event)
 {
     $wpUser = $event->getParameter('user');
     $user = $this->userManager->find($wpUser->data->ID);
     $user->setWordpressRoles($wpUser->roles);
     $token = new UsernamePasswordToken($user, $user->getPass(), 'secured_area', $user->getRoles());
     $this->securityContext->setToken($token);
     $this->session->set('token', $token);
 }