当前位置: 首页>>代码示例>>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;未经允许,请勿转载。