本文整理汇总了PHP中Claroline\CoreBundle\Entity\User::setUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setUsername方法的具体用法?PHP User::setUsername怎么用?PHP User::setUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::setUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
$this->om->persist($user);
if (!$this->userRole) {
$this->userRole = new Role();
$this->userRole->setName('ROLE_USER');
$this->userRole->setTranslationKey('user');
$this->om->persist($this->userRole);
}
$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);
$this->om->flush();
return $user;
}
示例2: user
/**
* @param string $username
*
* @return User
*/
public function user($username, $withWorkspace = false)
{
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
$user->setGuid($username);
$this->om->persist($user);
if (!$this->userRole) {
$this->userRole = $this->role('ROLE_USER');
$this->om->persist($this->userRole);
}
$user->addRole($this->userRole);
if ($withWorkspace) {
$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: loginAction
/**
* @EXT\Route(
* "/login",
* name="claro_o365_login"
* )
*
* @return RedirectResponse
*/
public function loginAction()
{
$this->authHelper->GetAuthenticationHeaderFor3LeggedFlow($_GET['code']);
$jsonResponse = $this->graphHelper->getMeEntry();
$userResponse = new O365ResponseUser($jsonResponse);
$userManager = $this->get('claroline.manager.user_manager');
$email = $userResponse->getEmail();
$user = $userManager->getUserByEmail($email);
if ($user === null) {
$missingProperties = $userResponse->validate();
if (count($missingProperties) > 0) {
return $this->render('FormaLibreOfficeConnectBundle:Authentication:missingProperties.html.twig', ['missingProperties' => $missingProperties]);
}
$user = new User();
$user->setFirstName($userResponse->getNickname());
$user->setLastName($userResponse->getRealName());
$user->setUsername($userResponse->getUsername());
$user->setPlainPassword($userResponse->getEmail());
$user->setMail($userResponse->getEmail());
$user->setIsMailValidated(true);
$userManager->createUser($user, false);
}
$userRepo = $this->get('doctrine.orm.entity_manager')->getRepository('ClarolineCoreBundle:User');
$securityContext = $this->get('security.context');
$userLoaded = $userRepo->loadUserByUsername($user->getUsername());
$providerKey = 'main';
$token = new UsernamePasswordToken($userLoaded, $userLoaded->getPassword(), $providerKey, $userLoaded->getRoles());
$securityContext->setToken($token);
$userManager->logUser($user);
return $this->get('claroline.authentication_handler')->onAuthenticationSuccess($this->get('request'), $token);
}
示例4: buildUser
private function buildUser($firstName, $lastName)
{
$user = new User();
$user->setFirstName($firstName);
$user->setLastName($lastName);
$user->setUsername($username = strtolower($firstName . $lastName));
$user->setPassword($username);
$user->setMail("{$username}@mail.com");
return $user;
}
示例5: persistUser
protected function persistUser($username)
{
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
$this->om->persist($user);
return $user;
}
示例6: load
public function load(ObjectManager $manager)
{
$userManager = $this->container->get('claroline.manager.user_manager');
foreach ($this->users as $properties) {
$user = new User();
$user->setUsername($properties['username']);
$user->setPlainPassword($properties['username']);
$user->setFirstName($properties['username']);
$user->setLastName($properties['username']);
$user->setMail($properties['username'] . '@claroline.net');
$user->setLocale('en');
$userManager->createUserWithRole($user, $properties['role']);
}
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = new User();
$user->setFirstName($input->getArgument('user_first_name'));
$user->setLastName($input->getArgument('user_last_name'));
$user->setUsername($input->getArgument('user_username'));
$user->setPlainPassword($input->getArgument('user_password'));
$user->setMail($input->getArgument('user_username') . '@claro.net');
if ($input->getOption('admin')) {
$roleName = PlatformRoles::ADMIN;
} elseif ($input->getOption('ws_creator')) {
$roleName = PlatformRoles::WS_CREATOR;
} else {
$roleName = PlatformRoles::USER;
}
$this->getContainer()->get('claroline.manager.user_manager')->createUserWithRole($user, $roleName);
}
示例8: 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;
}
示例9: user
/**
* @param string $username
* @return User
*/
public function user($username)
{
$roleUser = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
if (!$roleUser) {
$this->role('ROLE_USER');
$this->om->flush();
//we really need it
}
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
//much better
$this->container->get('claroline.manager.user_manager')->createUser($user, false);
return $user;
}
示例10: user
/**
* @param $username
*
* @return 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);
$this->om->persist($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;
}
示例11: getFromProviders
private function getFromProviders(TokenInterface $token, $providerKey)
{
$drivers = $this->authenticationManager->getDrivers();
foreach ($drivers as $driver) {
$found = $this->authenticationManager->authenticate($driver, $token->getUsername(), $token->getCredentials());
if ($found) {
$data = $this->authenticationManager->findUser($driver, $token->getUsername());
$user = new User();
$user->setFirstName($data['first_name']);
$user->setPlainPassword($data['password']);
$user->setLastName($data['last_name']);
$user->setUsername($data['username']);
$user->setMail($data['email']);
$user->setAuthentication($driver);
$iser = $this->userManager->createUser($user, false);
return new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
}
}
throw new AuthenticationException('Invalid username or password');
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = new User();
$user->setFirstName($input->getArgument('user_first_name'));
$user->setLastName($input->getArgument('user_last_name'));
$user->setUsername($input->getArgument('user_username'));
$user->setPlainPassword($input->getArgument('user_password'));
$email = $input->getArgument('user_email');
$email = filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : $email . '@debug.net';
$user->setMail($email);
if ($input->getOption('admin')) {
$roleName = PlatformRoles::ADMIN;
} elseif ($input->getOption('ws_creator')) {
$roleName = PlatformRoles::WS_CREATOR;
} else {
$roleName = PlatformRoles::USER;
}
$userManager = $this->getContainer()->get('claroline.manager.user_manager');
$consoleLogger = ConsoleLogger::get($output);
$userManager->setLogger($consoleLogger);
$userManager->createUser($user, false, [$roleName]);
}
示例13: 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;
}
示例14: postUserRegistrationAction
/**
* @Route("/new/user.{format}", name = "claro_register_user")
* @Method({"POST"})
*/
public function postUserRegistrationAction($format)
{
$formats = array('json', 'xml');
if (!in_array($format, $formats)) {
return new Response("The format {$format} is not supported (supported formats are 'json', 'xml')", 400);
}
$status = 200;
$content = array();
if ($this->configHandler->getParameter('allow_self_registration')) {
$request = $this->request;
$user = new User();
$user->setUsername($request->request->get('username'));
$user->setPlainPassword($request->request->get('password'));
$user->setFirstName($request->request->get('firstName'));
$user->setLastName($request->request->get('lastName'));
$user->setMail($request->request->get('mail'));
$errorList = $this->validator->validate($user);
if (count($errorList) > 0) {
$status = 422;
foreach ($errorList as $error) {
$content[] = array('property' => $error->getPropertyPath(), 'message' => $error->getMessage());
}
} else {
$this->userManager->createUser($user);
}
} else {
$status = 403;
}
return $format === 'json' ? new JsonResponse($content, $status) : new XmlResponse($content, $status);
}
示例15: importUsers
//.........这里部分代码省略.........
$group = new Group();
$group->setName($groupName);
$group = $this->groupManager->insertGroup($group);
}
} else {
$group = null;
}
$userEntity = $this->userRepo->findOneByMail($email);
if (!$userEntity) {
$userEntity = $this->userRepo->findOneByUsername($username);
if (!$userEntity && $code !== null) {
//the code isn't required afaik
$userEntity = $this->userRepo->findOneByAdministrativeCode($code);
}
}
if ($userEntity && $options['ignore-update']) {
if ($logger) {
$logger(" Skipping {$userEntity->getUsername()}...");
}
continue;
}
$isNew = false;
if (!$userEntity) {
$isNew = true;
$userEntity = new User();
$userEntity->setPlainPassword($pwd);
++$countCreated;
} else {
if (!empty($pwd)) {
$userEntity->setPlainPassword($pwd);
}
++$countUpdated;
}
$userEntity->setUsername($username);
$userEntity->setMail($email);
$userEntity->setFirstName($firstName);
$userEntity->setLastName($lastName);
$userEntity->setAdministrativeCode($code);
$userEntity->setPhone($phone);
$userEntity->setLocale($lg);
$userEntity->setAuthentication($authentication);
$userEntity->setIsMailNotified($isMailNotified);
$userEntity->setIsMailValidated($isMailValidated);
if ($options['single-validate']) {
$errors = $this->validator->validate($userEntity);
if (count($errors) > 0) {
$skipped[$i] = $userEntity;
if ($isNew) {
--$countCreated;
} else {
--$countUpdated;
}
continue;
}
}
if (!$isNew && $logger) {
$logger(" User {$j} ({$username}) being updated...");
$this->roleManager->associateRoles($userEntity, $additionalRoles);
}
if ($isNew) {
if ($logger) {
$logger(" User {$j} ({$username}) being created...");
}
$this->createUser($userEntity, $sendMail, $additionalRoles, $model, $username . uniqid(), $organizations, $hasPersonalWorkspace, false);
}
$this->objectManager->persist($userEntity);