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


PHP UserManager::loadUser方法代码示例

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


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

示例1: loadUserByUsername

 /**
  * @param string $username
  * @return User|null|object
  */
 public function loadUserByUsername($username)
 {
     $user = $this->userManager->loadUser($username);
     if ($user) {
         return $user;
     }
     throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:12,代码来源:AmpUserProvider.php

示例2: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $socialID = $response->getUsername();
     /** @var User $user */
     $user = $this->userManager->loadUser(['facebookId' => $socialID]);
     $update = true;
     $email = $response->getEmail();
     //check if the user already has the corresponding social account
     if (null === $user) {
         //check if the user has a normal account
         $user = $this->userManager->loadUser($email, 'email');
         if (null === $user || !$user instanceof UserInterface) {
             //if the user does not have a normal account, set it up:
             /** @var User $user */
             $name = $response->getNickname() ?? $response->getRealName();
             $user = $this->userManager->createUser($name, md5(uniqid()), $response->getEmail(), ['ROLE_OAUTH_USER']);
             $user->setEmail($email);
             $user->setFullName($name);
             $user->setEnabled(true);
             $violations = $this->validator->validate($user);
             $update = !$violations->count() === 0;
             if ($violations->count() === 0) {
                 $this->session->getFlashBag()->add('warning', 'Welcome! You must complete your profile in order to use the features on the site.');
             } else {
                 throw new CustomUserMessageAuthenticationException('An account in your name already exists.');
             }
         }
         if ($update) {
             //then set its corresponding social id
             $service = $response->getResourceOwner()->getName();
             switch ($service) {
                 case 'google':
                     $user->setGoogleID($socialID);
                     break;
                 case 'facebook':
                     $user->setFacebookID($socialID);
                     break;
             }
             $this->userManager->updateUser($user);
         }
     } else {
         //and then login the user
         $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
         $this->tokenStorage->setToken($token);
     }
     $user->setLastLoggedIn(new \DateTime());
     $this->userManager->updateUser($user);
     return $user;
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:49,代码来源:OAuthUserProvider.php

示例3: testUser

 /**
  * Tests creating, saving, editing User objects.
  */
 function testUser()
 {
     // elimino l'utente già creato in precedenza con questo nome.
     $u = UserManager::loadUserByNickname($this->user_data[NICKNAME]);
     //echo "<p>" . $u . "</p>"; //DEBUG
     if ($u !== false) {
         $u = UserManager::deleteUser($u);
         //echo "<p>" . $u . "</p>"; //DEBUG
     }
     $u = UserManager::loadUserByNickname($this->user_data2[NICKNAME]);
     if ($u !== false) {
         $u = UserManager::deleteUser($u);
     }
     $u = UserManager::createUser($this->user_data);
     //echo "<p>" . $u . "</p>"; //DEBUG
     $data = Filter::filterArray($this->user_data);
     if (isset($data[AVATAR])) {
         if ($u->getAvatar() != $data[AVATAR]) {
             return "User test NOT PASSED: avatar";
         }
     }
     if (isset($data[BIRTHDAY])) {
         if ($u->getBirthday() != $data[BIRTHDAY]) {
             return "User test NOT PASSED: birthday";
         }
     }
     if (isset($data[BIRTHPLACE])) {
         if ($u->getBirthplace() != $data[BIRTHPLACE]) {
             return "User test NOT PASSED: birthplace";
         }
     }
     if (isset($data[EMAIL])) {
         if ($u->getEMail() != $data[EMAIL]) {
             return "User test NOT PASSED: email";
         }
     }
     if (isset($data[GENDER])) {
         if ($u->getGender() != $data[GENDER]) {
             return "User test NOT PASSED: gender";
         }
     }
     if (isset($data[HOBBIES])) {
         if ($u->getHobbies() != $data[HOBBIES]) {
             return "User test NOT PASSED: hobbies";
         }
     }
     if (isset($data[JOB])) {
         if ($u->getJob() != $data[JOB]) {
             return "User test NOT PASSED: job";
         }
     }
     if (isset($data[LIVING_PLACE])) {
         if ($u->getLivingPlace() != $data[LIVING_PLACE]) {
             return "User test NOT PASSED: living place";
         }
     }
     if (isset($data[NAME])) {
         if ($u->getName() != $data[NAME]) {
             return "User test NOT PASSED: name";
         }
     }
     if (isset($data[NICKNAME])) {
         if ($u->getNickname() != $data[NICKNAME]) {
             return "User test NOT PASSED: nickname";
         }
     }
     if (isset($data[PASSWORD])) {
         if ($u->getPassword() != $data[PASSWORD]) {
             return "User test NOT PASSED: password";
         }
     }
     if (isset($data[ROLE])) {
         if ($u->getRole() != $data[ROLE]) {
             return "User test NOT PASSED: role";
         }
     }
     if (isset($data[SURNAME])) {
         if ($u->getSurname() != $data[SURNAME]) {
             return "User test NOT PASSED: surname";
         }
     }
     if (isset($data[VISIBLE])) {
         if ($u->getVisible() != $data[VISIBLE]) {
             return "User test NOT PASSED: visible";
         }
     }
     // TEST LOAD
     $u2 = UserManager::loadUser($u->getID());
     //echo "<p>" . $u . "<br />" . $u2 . "</p>"; //DEBUG
     if ($u->getAvatar() != $u2->getAvatar()) {
         return "User test NOT PASSED: avatar not loaded";
     }
     //echo "<p>" . $u->getBirthday() . "<br />" . $u2->getBirthday() . " - " . time() . "</p>"; //DEBUG
     if ($u->getBirthday() != $u2->getBirthday()) {
         return "User test NOT PASSED: birthday not loaded";
     }
     if ($u->getBirthplace() != $u2->getBirthplace()) {
//.........这里部分代码省略.........
开发者ID:Esisto,项目名称:IoEsisto,代码行数:101,代码来源:UserTest.php

示例4: getAuthorName

 function getAuthorName()
 {
     require_once "user/UserManager.php";
     if (is_null($this->getAuthor())) {
         return "Anonimous";
     }
     $u = UserManager::loadUser($this->getAuthor(), false);
     if (!is_null($u->getNickname())) {
         return $u->getNickname();
     }
     return $this->getAuthor();
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:12,代码来源:Post.php

示例5: PCSameAuthor

 private static function PCSameAuthor($data)
 {
     if (isset(self::$currentObject) && !is_null(self::$currentObject) && self::$currentObject !== false) {
         require_once 'user/UserManager.php';
         $user = UserManager::loadUser(self::$currentObject->getAuthor(), false);
         if (true) {
             //TODO se l'autore vuole
             echo "<p>Dello stesso autore</p>";
             require_once 'search/SearchManager.php';
             $posts = SearchManager::searchBy("Post", array("author" => $user->getID(), "no_id" => self::$currentObject->getID(), "loadComments" => false), array("order" => -1, "by" => "ps_creationDate"));
             self::$post_options[PostPage::SHORT] = true;
             self::$post_options[PostPage::NO_COMMENTS] = true;
             self::$post_options[PostPage::NO_MODIF_DATE] = true;
             require_once 'post/PostPage.php';
             foreach ($posts as $p) {
                 PostPage::showPost($p, self::$post_options);
             }
             self::$post_options[PostPage::SHORT] = false;
             self::$post_options[PostPage::NO_COMMENTS] = false;
             self::$post_options[PostPage::NO_MODIF_DATE] = false;
         }
     }
 }
开发者ID:Esisto,项目名称:IoEsisto,代码行数:23,代码来源:page.php


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