當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setLastName方法代碼示例

本文整理匯總了PHP中Claroline\CoreBundle\Entity\User::setLastName方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setLastName方法的具體用法?PHP User::setLastName怎麽用?PHP User::setLastName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Claroline\CoreBundle\Entity\User的用法示例。


在下文中一共展示了User::setLastName方法的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);
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:39,代碼來源:OfficeConnectController.php

示例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();
     }
 }
開發者ID:ngydat,項目名稱:CoreBundle,代碼行數:37,代碼來源:LoadUserData.php

示例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;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:31,代碼來源:Persister.php

示例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;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:27,代碼來源:Persister.php

示例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;
 }
開發者ID:stefk,項目名稱:CompetencyBundle,代碼行數:10,代碼來源:UserFixture.php

示例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;
 }
開發者ID:stefk,項目名稱:CompetencyBundle,代碼行數:11,代碼來源:RepositoryTestCase.php

示例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']);
     }
 }
開發者ID:ChMat,項目名稱:CoreBundle,代碼行數:14,代碼來源:LoadUserData.php

示例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);
 }
開發者ID:ChMat,項目名稱:CoreBundle,代碼行數:17,代碼來源:CreateUserCommand.php

示例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;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:23,代碼來源:Persister.php

示例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;
 }
開發者ID:ngydat,項目名稱:CoreBundle,代碼行數:22,代碼來源:Persister.php

示例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');
 }
開發者ID:ngydat,項目名稱:CoreBundle,代碼行數:20,代碼來源:ExternalAuthenticator.php

示例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;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:25,代碼來源:Persister.php

示例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]);
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:22,代碼來源:CreateUserCommand.php

示例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;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:24,代碼來源:Persister.php

示例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);
 }
開發者ID:ChMat,項目名稱:CoreBundle,代碼行數:34,代碼來源:RegistrationController.php


注:本文中的Claroline\CoreBundle\Entity\User::setLastName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。