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


PHP UserManagerInterface::createUser方法代碼示例

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


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

示例1: create

 /**
  * Creates a user and returns it.
  *
  * @param string $username
  * @param string $password
  * @param string $email
  * @param bool   $active
  * @param bool   $superadmin
  *
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $active, $superadmin)
 {
     $discriminator = $this->discriminator;
     switch ($this->type) {
         case 'staff':
             $class = 'Truckee\\MatchBundle\\Entity\\Staff';
             break;
         case 'admin':
             $class = 'Truckee\\MatchBundle\\Entity\\Admin';
             break;
         case 'volunteer':
             $class = 'Truckee\\MatchBundle\\Entity\\Volunteer';
             break;
         default:
             break;
     }
     $discriminator->setClass($class);
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setFirstname($this->firstname);
     $user->setLastname($this->lastname);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled((bool) $active);
     $this->userManager->updateUser($user, true);
     return $user;
 }
開發者ID:truckee,項目名稱:match,代碼行數:38,代碼來源:UserManipulator.php

示例2: create

 public function create()
 {
     /** @var User $user */
     $user = $this->userManager->createUser();
     $user->setPlainPassword(md5(rand(1000000, 9999999), false));
     $user->setEnabled(true);
     return $user;
 }
開發者ID:Exanrus,項目名稱:crm-bundle,代碼行數:8,代碼來源:UserManager.php

示例3: createUserFromResponse

 /**
  * Create user from response
  *
  * @param UserResponseInterface $response
  *
  * @return User
  */
 private function createUserFromResponse(UserResponseInterface $response)
 {
     /** @var User $user User */
     $user = $this->userManager->createUser();
     $user->setUsername($response->getUsername())->setFullName($response->getRealName())->setEmail($response->getEmail())->setEnabled(true)->setPlainPassword(uniqid())->setFacebookId($response->getUsername())->setFacebookAccessToken($response->getAccessToken());
     $this->eventDispatcher->dispatch(AppEvents::FACEBOOK_USER_CONNECTED, new FacebookUserConnectedEvent($user));
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:stfalcon-studio,項目名稱:lost-and-found,代碼行數:16,代碼來源:AuthProvider.php

示例4: create

 /**
  * Creates a user and returns it.
  *
  * @param string $username
  * @param string $password
  * @param string $email
  * @param Boolean $active
  * @param Boolean $superadmin
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $active, $superadmin)
 {
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled((bool) $active);
     $user->setSuperAdmin((bool) $superadmin);
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:nightchiller,項目名稱:UserBundle,代碼行數:21,代碼來源:UserManipulator.php

示例5: create

 /**
  * Creates a user and returns it.
  *
  * @param string $email
  * @param string $password
  * @param string $fullname
  * @param string $institution
  * @param bool   $active
  * @param bool   $superadmin
  *
  * @return User
  */
 public function create($email, $password, $fullname, $institution, $active, $superadmin)
 {
     $user = $this->userManager->createUser();
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setFullname($fullname);
     $user->setInstitution($institution);
     $user->setEnabled($active);
     $user->setSuperAdmin($superadmin);
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:ubermichael,項目名稱:pkppln-php,代碼行數:24,代碼來源:UserManipulator.php

示例6: registerUser

 /**
  * @param $email
  * @param $password
  * @return \FOS\UserBundle\Model\UserInterface
  * @throws ValidationException
  */
 public function registerUser($email, $password)
 {
     $user = $this->userManager->createUser();
     $user->setUsername($email);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled(true);
     $errors = $this->validator->validate($user, null, array('registration'));
     if ($errors->count() > 0) {
         throw new ValidationException($errors);
     }
     $this->userManager->updateUser($user);
     return UserDTO::withEntity($user);
 }
開發者ID:sfarkas1988,項目名稱:timekeepingAPI,代碼行數:20,代碼來源:UserService.php

示例7: create

 /**
  * Creates a user and returns it.
  *
  * @param string  $username
  * @param string  $password
  * @param string  $email
  * @param Boolean $active
  * @param Boolean $superadmin
  *
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $active, $superadmin, $company, $legalSituation, $phoneNumber, $url)
 {
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled((bool) $active);
     $user->setSuperAdmin((bool) $superadmin);
     $user->setCompany($company);
     $user->setLegalSituation($legalSituation);
     $user->setPhoneNumber($phoneNumber);
     $user->setUrl($url);
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:StanFrag,項目名稱:CCM-Stage,代碼行數:26,代碼來源:UserManipulator.php

示例8: create

 /**
  * Creates a user and returns it.
  *
  * @param string $username
  * @param string $password
  * @param string $email
  * @param string $name
  * @param string $lastName
  * @param bool   $active
  * @param bool   $superadmin
  *
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $name, $lastName, $active, $superadmin, $changePassword)
 {
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setName($name);
     $user->setLastName($lastName);
     $user->setEnabled((bool) $active);
     $user->setSuperAdmin((bool) $superadmin);
     if ((bool) $changePassword) {
         $user->setPasswordExpireAt(new \DateTime());
     }
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:tkuska,項目名稱:user,代碼行數:29,代碼來源:UserManipulator.php

示例9: fixAnonymousUser

 /**
  * Fixes the user, Drupal does not provide a hook for anonymous user
  */
 public function fixAnonymousUser()
 {
     global $user;
     if (!$user || $user->uid != 0) {
         return;
     }
     $user = $this->userManager->createUser()->fromDrupalUser($user);
 }
開發者ID:Djecan,項目名稱:EkinoDrupalBundle,代碼行數:11,代碼來源:Drupal.php

示例10: createUserFromResponse

 /**
  * Create user from response
  *
  * @param UserResponseInterface $response
  *
  * @return User
  */
 private function createUserFromResponse(UserResponseInterface $response)
 {
     $email = $response->getEmail() ?: $response->getUsername() . '@example.com';
     /** @var User $user */
     $user = $this->userManager->createUser();
     $user->setEmail($email);
     $user->setUsername($response->getNickname());
     $user->setEnabled(true);
     $user->setPlainPassword(uniqid());
     $user->setGithubId($response->getUsername());
     // Move to separate listener
     if (in_array($response->getUsername(), $this->adminGitHubIds)) {
         $user->addRole('ROLE_ADMIN');
     }
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:stfalcon-studio,項目名稱:codedill,代碼行數:24,代碼來源:AuthProvider.php

示例11: create

 /**
  * Creates a user and returns it.
  *
  * @param string  $username
  * @param string  $password
  * @param string  $email
  * @param Boolean $active
  * @param Boolean $superadmin
  * @param array   $userproperties
  *
  * @return \FOS\UserBundle\Model\UserInterface
  */
 public function create($username, $password, $email, $active, $superadmin, $userproperties = null)
 {
     $user = $this->userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled((bool) $active);
     $user->setSuperAdmin((bool) $superadmin);
     if (!is_null($userproperties) && is_array($userproperties) && count($userproperties) > 0) {
         foreach ($userproperties as $method => $value) {
             if (method_exists($user, $method)) {
                 $user->{$method}($value);
             }
         }
     }
     $this->userManager->updateUser($user);
     return $user;
 }
開發者ID:enekochan,項目名稱:FOSUserBundle,代碼行數:30,代碼來源:UserManipulator.php

示例12: process

 /**
  * @param \Hatimeria\ExtJSBundle\Parameter\ParameterBag $params
  * @param mixed $user
  * @return \Hatimeria\ExtJSBundle\Response\Form
  */
 public function process($params, $user = null)
 {
     $validationGroup = 'Profile';
     if (null === $user) {
         $validationGroup = 'Registration';
         $user = $this->um->createUser();
     }
     $options = array('data_class' => $this->userClass, 'validation_groups' => array($validationGroup));
     $type = new UserFormType();
     $type->setExtend($this->extensionCollector->getExtensions());
     $form = $this->formFactory->create($type, $user, $options);
     $form->bind($params->all());
     $result = new Form($form);
     if ($result->isValid()) {
         $this->um->updateUser($user);
         return $user;
     }
     return $result;
 }
開發者ID:hatimeria,項目名稱:HatimeriaAdminBundle,代碼行數:24,代碼來源:UserFormHandler.php

示例13: createPrincipal

 /**
  * Creates a new principal.
  *
  * This method receives a full path for the new principal. The mkCol object
  * contains any additional webdav properties specified during the creation
  * of the principal.
  *
  * @param string $path
  * @param MkCol  $mkCol
  */
 public function createPrincipal($path, MkCol $mkCol)
 {
     // create new user
     $username = str_replace('principal/', '', $path);
     $user = $this->user_manager->createUser();
     $user->setUsername($username);
     $user->setForename($username);
     $this->_em->persist($user);
     $this->_em->flush();
 }
開發者ID:bartv2,項目名稱:SecotrustSabreDavBundle,代碼行數:20,代碼來源:PrincipalBackend.php

示例14: loadUserByOAuthUserResponse

 /**
  * {@inheritDoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $userInfo = $this->getUserInfo($response);
     $service = $response->getResourceOwner()->getName();
     $user = $this->userManager->findUserBy(array("{$service}Id" => $userInfo['id']));
     if ($user instanceof PersonInterface) {
         $user = parent::loadUserByOAuthUserResponse($response);
         $serviceName = $response->getResourceOwner()->getName();
         $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
         $user->{$setter}($response->getAccessToken());
         return $user;
     }
     $userInfo = $this->checkEmail($service, $userInfo);
     $user = $this->userManager->createUser();
     $this->setUserInfo($user, $userInfo, $service);
     if ($userInfo['first_name']) {
         $user->setFirstName($userInfo['first_name']);
     }
     if ($userInfo['family_name']) {
         $user->setSurname($userInfo['family_name']);
     }
     if ($service === 'facebook') {
         $this->setFacebookData($user, $response->getResponse());
     }
     $username = Uuid::uuid4()->toString();
     if (!UsernameValidator::isUsernameValid($username)) {
         $username = UsernameValidator::getValidUsername();
     }
     $availableUsername = $this->userManager->getNextAvailableUsername($username, 10, Uuid::uuid4()->toString());
     $user->setUsername($availableUsername);
     $user->setEmail($userInfo['email']);
     $user->setPassword('');
     $user->setEnabled(true);
     $this->userManager->updateCanonicalFields($user);
     /** @var ValidatorInterface $validator */
     $validator = $this->container->get('validator');
     /** @var ConstraintViolationList $errors */
     $errors = $validator->validate($user, ['LoginCidadaoProfile']);
     if (count($errors) > 0) {
         foreach ($errors as $error) {
             if ($error->getPropertyPath() === 'email' && method_exists($error, 'getConstraint') && $error->getConstraint() instanceof UniqueEntity) {
                 throw new DuplicateEmailException($service);
             }
         }
     }
     $form = $this->formFactory->createForm();
     $form->setData($user);
     $request = $this->container->get('request');
     $eventResponse = new RedirectResponse('/');
     $event = new FormEvent($form, $request);
     $this->dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
     $this->userManager->updateUser($user);
     $this->dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $eventResponse));
     return $user;
 }
開發者ID:redelivre,項目名稱:login-cidadao,代碼行數:58,代碼來源:FOSUBUserProvider.php

示例15: create

 /**
  * Creates a new Resource from the given parameters.
  *
  * @param FormInterface $form
  *
  * @return Resource
  */
 public function create(FormInterface $form)
 {
     $formData = $form->getData();
     /** @var UserEntity $user */
     $user = $this->userManager->createUser();
     $user->setUsername($formData['username']);
     $user->setEmail($formData['email']);
     $user->setPlainPassword($formData['password']);
     $user->setEnabled(true);
     $this->userManager->updateUser($user);
     return $this->createResourceFromUser($user);
 }
開發者ID:ingewikkeld,項目名稱:rest-user-bundle,代碼行數:19,代碼來源:User.php


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