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