当前位置: 首页>>代码示例>>PHP>>正文


PHP UserProviderInterface::createUser方法代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserProviderInterface::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProviderInterface::createUser方法的具体用法?PHP UserProviderInterface::createUser怎么用?PHP UserProviderInterface::createUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Security\Core\User\UserProviderInterface的用法示例。


在下文中一共展示了UserProviderInterface::createUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createUser

 /**
  * Create a user with the provided username.
  *
  * @param string $username
  *
  * @return UserInterface $user
  */
 protected function createUser($username)
 {
     if (!$this->userProvider instanceof UserFactoryInterface) {
         throw new AuthenticationServiceException("UserProvider must implement UserFactoryInterface to create unknown users.");
     }
     $user = $this->userProvider->createUser($username);
     if (!$user instanceof UserInterface) {
         throw new AuthenticationServiceException("The user provider must return a UserInterface object.");
     }
     return $user;
 }
开发者ID:PrincetonUniversity,项目名称:PucsCasAuthBundle,代码行数:18,代码来源:CasAuthenticationProvider.php

示例2: createUser

 /**
  * @throws AuthenticationServiceException
  *
  * @param string $username
  * @param array $attributes
  *
  * @return UserInterface
  */
 protected function createUser($username, array $attributes = array())
 {
     if (!$this->userProvider instanceof UserFactoryInterface) {
         throw new AuthenticationServiceException('UserProvider must implement UserFactoryInterface to create unknown users.');
     }
     try {
         $user = $this->userProvider->createUser($username, $this->createdUsersRoles, $attributes);
         if (!$user instanceof UserInterface) {
             throw new AuthenticationServiceException('The user provider must create an UserInterface object.');
         }
     } catch (\Exception $repositoryProblem) {
         throw new AuthenticationServiceException($repositoryProblem->getMessage(), $username, 0, $repositoryProblem);
     }
     return $user;
 }
开发者ID:nicolasbui,项目名称:BeSimpleSsoAuthBundle,代码行数:23,代码来源:SsoAuthenticationProvider.php

示例3: createUser

 /**
  * Creates a new User.
  *
  * @param array $data
  * @param bool  $isOAuth
  *
  * @return UserInterface $user
  */
 protected function createUser(array $data, UserProviderInterface $userManager)
 {
     $userIdentityfield = $this->container->getParameter('rch_jwt_user.user_identity_field');
     $user = $userManager->createUser()->setUsername($data[$userIdentityfield])->setEmail($data[$userIdentityfield])->setEnabled(true)->setPlainPassword($data['password']);
     if (isset($data['facebook_id'])) {
         $user->setFacebookId($data['facebook_id']);
     }
     try {
         $userManager->updateUser($user);
     } catch (\Exception $e) {
         $message = $e->getMessage() ?: 'An error occured while creating the user.';
         throw new UserException(422, $message, $e);
     }
     return $user;
 }
开发者ID:chalasr,项目名称:RCHJWTUserBundle,代码行数:23,代码来源:SecurityController.php


注:本文中的Symfony\Component\Security\Core\User\UserProviderInterface::createUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。