當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserInterface::getRoles方法代碼示例

本文整理匯總了PHP中FOS\UserBundle\Model\UserInterface::getRoles方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserInterface::getRoles方法的具體用法?PHP UserInterface::getRoles怎麽用?PHP UserInterface::getRoles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FOS\UserBundle\Model\UserInterface的用法示例。


在下文中一共展示了UserInterface::getRoles方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRedirectionUrl

 /**
  * {@inheritdoc}
  */
 protected function getRedirectionUrl(UserInterface $user)
 {
     $rolesTab = $user->getRoles();
     if (in_array('ROLE_ADMIN', $rolesTab, true) || in_array('ROLE_SUPER_ADMIN', $rolesTab, true)) {
         return $this->container->get('router')->generate('sonata_admin_dashboard');
     } else {
         return $this->container->get('router')->generate('sonata_user_profile_show');
     }
 }
開發者ID:WildCodeSchool,項目名稱:projet-wiki_des_maires,代碼行數:12,代碼來源:ChangePasswordFOSUser1Controller.php

示例2: updateRoles

 /**
  *
  */
 public function updateRoles(UserInterface $user)
 {
     $roles = $user->getRoles();
     $roleRepository = $this->objectManager->getRepository('WeavingTheWebUserBundle:Role');
     foreach ($roles as $role) {
         $roleName = (string) $role;
         $roleEntity = $roleRepository->findOneByRole($roleName);
         $user->removeRole($role);
         $user->addRole($roleEntity);
     }
 }
開發者ID:WeavingTheWeb,項目名稱:devobs,代碼行數:14,代碼來源:UserManager.php

示例3: SamlUser

 function it_load_user_by_username(SamlAuth $auth, UserInterface $user, UserManagerInterface $userManager)
 {
     $auth->getAttributes()->shouldBeCalled();
     $auth->getUsername()->shouldBeCalled();
     $auth->isAuthenticated()->shouldBeCalled();
     $user->getUsername()->shouldBeCalled();
     $user->getRoles()->shouldBeCalled();
     $userManager->findUserByUsername(self::USERNAME)->shouldBeCalled();
     $samlUser = new SamlUser('user@domain.com', ['ROLE_USER'], []);
     $this->loadUserByUsername('user@domain.com')->shouldBeLike($samlUser);
 }
開發者ID:aulasoftwarelibre,項目名稱:CeepsUserBundle,代碼行數:11,代碼來源:FosBackendSamlUserProviderSpec.php

示例4: createToken

 protected function createToken($firewall, UserInterface $user)
 {
     return new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
 }
開發者ID:aoll,項目名稱:Framework,代碼行數:4,代碼來源:LoginManager.php

示例5: userLoginAction

 /**
  * add the symfony-login "manually".
  * 
  * use the symfony token-storage for the generated UsernamePasswordToken 
  * to access the (logged in) user later (e.g. to check for roles or permissions)
  * 
  * the given $passwordHash must match the encrypted password in the user-object
  * 
  * before and after the generation/setting of the token, the events "secotrust.user_login.before" 
  * and "secotrust.user_login.after" are called, if some EventListeners are configured
  *
  * @param \FOS\UserBundle\Model\UserInterface $user
  * @param $passwordHash
  */
 private function userLoginAction(\FOS\UserBundle\Model\UserInterface $user, $passwordHash)
 {
     // call the pre-login-event
     $event = new Event();
     $this->dispatcher->dispatch('secotrust.user_login.before', $event);
     if ($user->getPassword() !== $passwordHash) {
         // stop the login-action, when the password doesn't match
         return;
     }
     $token = new UsernamePasswordToken($user, null, 'secured_area', $user->getRoles());
     $this->token_storage->setToken($token);
     // call the post-login-event
     $event = new Event();
     $this->dispatcher->dispatch('secotrust.user_login.after', $event);
 }
開發者ID:bartv2,項目名稱:SecotrustSabreDavBundle,代碼行數:29,代碼來源:AuthBackend.php

示例6: authenticateUser

 /**
  * Authenticate a user with Symfony Security
  *
  * @param \FOS\UserBundle\Model\UserInterface $user
  */
 protected function authenticateUser(UserInterface $user)
 {
     $providerKey = $this->container->getParameter('fos_user.firewall_name');
     $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
     $this->container->get('security.context')->setToken($token);
 }
開發者ID:Anmoldev,項目名稱:FOSUserBundle,代碼行數:11,代碼來源:RegistrationController.php

示例7: authenticateUser

 /**
  * Authenticate a user with Symfony Security
  *
  * @param Boolean $reAuthenticate
  * @return null
  */
 protected function authenticateUser(UserInterface $user, $reAuthenticate = false)
 {
     $providerKey = $this->container->getParameter('fos_user.provider_key');
     $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
     if (true === $reAuthenticate) {
         $token->setAuthenticated(false);
     }
     $this->container->get('security.context')->setToken($token);
 }
開發者ID:KnpLabs,項目名稱:KnpUserBundle,代碼行數:15,代碼來源:UserController.php


注:本文中的FOS\UserBundle\Model\UserInterface::getRoles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。