本文整理汇总了PHP中Claroline\CoreBundle\Entity\User::setFirstName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setFirstName方法的具体用法?PHP User::setFirstName怎么用?PHP User::setFirstName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::setFirstName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $objectManager)
{
/** @var \Claroline\CoreBundle\Manager\UserManager $userCreator */
$userCreator = $this->container->get('claroline.manager.user_manager');
/** @var \Claroline\CoreBundle\Manager\RoleManager $roleManager */
$roleManager = $this->container->get('claroline.manager.role_manager');
/** @var \Claroline\CoreBundle\Repository\ResourceNodeRepository $resourceRepo */
$resourceRepo = $objectManager->getRepository('ClarolineCoreBundle:Resource\\ResourceNode');
foreach ($this->users as $names => $role) {
$namesArray = explode(' ', $names);
$firstName = $namesArray[0];
$lastName = isset($namesArray[1]) ? $namesArray[1] : '';
$username = $firstName . ucfirst($lastName);
$user = new User();
$user->setAdministrativeCode('UCL-' . $username . '-' . rand(0, 1000));
$user->setFirstName($firstName);
$lastName = $lastName == '' ? 'Doe' : $lastName;
$user->setLastName($lastName);
$user->setUserName($username);
$user->setPlainPassword($username);
$user->setMail('mail_' . uniqid() . '@claroline.net');
$objectManager->persist($user);
$roleManager->associateRole($user, $this->getReference("role/{$role}"));
if ($this->withWorkspace) {
$userCreator->createUser($user);
$this->addReference("workspace/{$names}", $user->getPersonalWorkspace());
$this->addReference("directory/{$names}", $resourceRepo->findWorkspaceRoot($user->getPersonalWorkspace()));
} else {
$objectManager->persist($user);
}
$this->addReference("user/{$names}", $user);
$objectManager->flush();
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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']);
}
}
示例8: 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);
}
示例9: 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;
}
示例10: 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;
}
示例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: 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;
}
示例13: 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]);
}
示例14: 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;
}
示例15: 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);
}