本文整理汇总了PHP中Claroline\CoreBundle\Entity\User::setPublicUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPublicUrl方法的具体用法?PHP User::setPublicUrl怎么用?PHP User::setPublicUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::setPublicUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user
/**
* @param string $username
*
* @return User
*/
public function user($username)
{
$roleUser = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPlainPassword($username);
$user->setMail($username . '@mail.com');
$user->setGuid(uniqid());
$user->addRole($roleUser);
$user->setPublicUrl($username);
$user->setCreationDate(new \DateTime());
$this->container->get('claroline.manager.role_manager')->createUserRole($user);
$this->om->persist($user);
$this->om->flush();
return $user;
}
示例2: user
public function user($username)
{
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
$user->setGuid($username);
$user->setPublicUrl($username);
$this->om->persist($user);
if (!$this->userRole) {
$this->userRole = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
}
$user->addRole($this->userRole);
$workspace = new Workspace();
$workspace->setName($username);
$workspace->setCreator($user);
$workspace->setCode($username);
$workspace->setGuid($username);
$this->om->persist($workspace);
$user->setPersonalWorkspace($workspace);
return $user;
}
示例3: 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;
}