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


PHP User::setEmailValidationHash方法代码示例

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


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

示例1: createUser

 /**
  * Create a user.
  * Its basic properties (name, username,... ) must already be set.
  *
  * @param \Claroline\CoreBundle\Entity\User $user
  * @param bool                              $sendMail         do we need to mail the new user ?
  * @param array                             $additionnalRoles a list of additionalRoles
  * @param Model                             $model            a model to create workspace
  *
  * @return \Claroline\CoreBundle\Entity\User
  */
 public function createUser(User $user, $sendMail = true, $rolesToAdd = [], $model = null, $publicUrl = null, $organizations = [], $forcePersonalWorkspace = null, $forceRoleValidation = true)
 {
     $additionnalRoles = [];
     foreach ($rolesToAdd as $roleToAdd) {
         $additionnalRoles[] = is_string($roleToAdd) ? $this->roleManager->getRoleByName($roleToAdd) : $roleToAdd;
     }
     if (count($organizations) === 0 && count($user->getOrganizations()) === 0) {
         $organizations = [$this->organizationManager->getDefault(true)];
         $user->setOrganizations($organizations);
     }
     $this->objectManager->startFlushSuite();
     $user->setGuid($this->container->get('claroline.utilities.misc')->generateGuid());
     $user->setEmailValidationHash($this->container->get('claroline.utilities.misc')->generateGuid());
     $user->setOrganizations($organizations);
     $publicUrl ? $user->setPublicUrl($publicUrl) : $user->setPublicUrl($this->generatePublicUrl($user));
     $this->toolManager->addRequiredToolsToUser($user, 0);
     $this->toolManager->addRequiredToolsToUser($user, 1);
     $roleUser = $this->roleManager->getRoleByName(PlatformRoles::USER);
     $user->addRole($roleUser);
     $this->roleManager->createUserRole($user);
     foreach ($additionnalRoles as $role) {
         if ($role) {
             $this->roleManager->associateRole($user, $role);
         }
     }
     if ($this->mailManager->isMailerAvailable() && $sendMail) {
         //send a validation by hash
         $mailValidation = $this->platformConfigHandler->getParameter('registration_mail_validation');
         if ($mailValidation === PlatformConfiguration::REGISTRATION_MAIL_VALIDATION_FULL) {
             $password = sha1(rand(1000, 10000) . $user->getUsername() . $user->getSalt());
             $user->setResetPasswordHash($password);
             $user->setIsEnabled(false);
             $this->mailManager->sendEnableAccountMessage($user);
         } elseif ($mailValidation === PlatformConfiguration::REGISTRATION_MAIL_VALIDATION_PARTIAL) {
             //don't change anything
             $this->mailManager->sendCreationMessage($user);
         }
     }
     if ($forcePersonalWorkspace !== null) {
         if ($forcePersonalWorkspace) {
             $this->setPersonalWorkspace($user, $model);
         }
     } else {
         if ($this->personalWorkspaceAllowed($additionnalRoles)) {
             $this->setPersonalWorkspace($user, $model);
         }
     }
     $this->objectManager->persist($user);
     $this->strictEventDispatcher->dispatch('user_created_event', 'UserCreated', ['user' => $user]);
     $this->strictEventDispatcher->dispatch('log', 'Log\\LogUserCreate', [$user]);
     $this->objectManager->endFlushSuite();
     return $user;
 }
开发者ID:claroline,项目名称:distribution,代码行数:64,代码来源:UserManager.php


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