當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。