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


PHP User::getUsername方法代碼示例

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


在下文中一共展示了User::getUsername方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateUserInfosWithLdap

 /**
  * @param User $user
  */
 public function updateUserInfosWithLdap(User $user)
 {
     try {
         $datas = $this->ldap->getDataByUid($user->getUsername());
         $user->setFirstName($datas['givenname'][0]);
         $user->setLastName($datas['sn'][0]);
         $user->setEmail($datas['mail'][0]);
         $user->setPlainPassword(md5(uniqid(rand(), true)));
         $user->setPhoto(base64_encode($datas['jpegphoto'][0]));
     } catch (\Exception $e) {
         throw new UsernameNotFoundException(sprintf('Impossible de trouver %s dans le LDAP', $user->getUsername()));
     }
 }
開發者ID:sghribi,項目名稱:garopi,代碼行數:16,代碼來源:UserService.php

示例2: createToken

 /**
  * @param User $user
  * @return Token
  */
 public function createToken(User $user) : Token
 {
     $issued = Carbon::now();
     $expire = Carbon::now()->addSeconds((int) $this->config['expire']);
     $notBefore = Carbon::now()->addSeconds((int) $this->config['notbefore']);
     return $this->tokenBuilder->setIssuer($this->config['issuer'])->setAudience($this->config['audience'])->setId($this->config['appid'], true)->setIssuedAt($issued->getTimestamp())->setNotBefore($notBefore->getTimestamp())->setExpiration($expire->getTimestamp())->set('data', ["uid" => $user->getId(), "uidentifier" => $user->getUsername()])->sign($this->signer, $this->secret)->getToken();
 }
開發者ID:Algatux,項目名稱:symfony3.0,代碼行數:11,代碼來源:TokenGenerator.php

示例3: getUserAction

 /**
  * @Route("/users/:{id}", name="rest_user")
  * @param User $user
  * @return array
  * @View()
  * @ParamConverter("user",class="AppBundle:User")
  */
 public function getUserAction(User $user)
 {
     $em = $this->getDoctrine()->getManager();
     $users = $em->getRepository('AppBundle:User')->findAll();
     // get data, in this case list of users.
     return array('user' => array('login' => $user->getUsername(), 'email' => $user->getEmail(), 'adresse' => $user->getAdresse(), 'telephone' => $user->getNumero(), 'sitweb' => $user->getSiteweb()));
 }
開發者ID:KtuluWU,項目名稱:Carnet-d-adresses,代碼行數:14,代碼來源:RestController.php

示例4: transform

 /**
  * Transforms an object (user) to a string (username).
  *
  * @param  User|null $user
  * @return string
  */
 public function transform($user)
 {
     if (null === $user) {
         return '';
     }
     return $user->getUsername();
 }
開發者ID:iliegurzun,項目名稱:articleapi,代碼行數:13,代碼來源:UserToStringTransformer.php

示例5: toEleveur

 /**
  * Créé une page eleveur à l'utilisateur connecté
  * @return $this
  * @throws HistoryException
  */
 public function toEleveur()
 {
     /** @var PageEleveurService $pageEleveurService */
     $pageEleveurService = $this->client->getContainer()->get('zigotoo.page_eleveur');
     // l'elevage aussi contiendra le random de par le username
     $this->pageEleveur = $pageEleveurService->create('elevage_' . $this->user->getUsername(), $this->user);
     return $this;
 }
開發者ID:apflieger,項目名稱:zigotoo,代碼行數:13,代碼來源:TestUtils.php

示例6: testSetEmail

 /**
  * Tests if the username property is set, if its not set while setting the email
  */
 public function testSetEmail()
 {
     $user = new User();
     $this->assertNull($user->getEmail());
     $user->setEmail('foo@bar.com');
     $this->assertEquals($user->getEmail(), $user->getUsername());
     $secondUser = new User();
     $secondUser->setUsername('username');
     $secondUser->setEmail('foo@bar.com');
     $this->assertNotEquals($secondUser->getEmail(), $secondUser->getUsername());
 }
開發者ID:avanthay,項目名稱:timekipr,代碼行數:14,代碼來源:UserTest.php

示例7: testBasicGettersSetters

 public function testBasicGettersSetters()
 {
     $user = new User();
     $user->setUsername('Toto');
     $user->setEmail('toto@tata.com');
     $user->setIsActive(false);
     $user->setPassword('1234');
     $this->assertEquals('Toto', $user->getUsername());
     $this->assertEquals('toto@tata.com', $user->getEmail());
     $this->assertEquals(false, $user->isActive());
     $this->assertEquals('1234', $user->getPassword());
 }
開發者ID:Pamoi,項目名稱:photo-gallery-api,代碼行數:12,代碼來源:UserTest.php

示例8: transform

 /**
  * Transform a Model User to its representation.
  *
  * @param User|null $user
  *
  * @return UserRepresentation|null
  */
 public function transform($user)
 {
     if (!$user) {
         return;
     }
     $representation = new UserRepresentation();
     $representation->setId($user->getId());
     $representation->setUsername($user->getUsername());
     $representation->setEmail($user->getEmail());
     $representation->setFirstname($user->getFirstName());
     return $representation;
 }
開發者ID:bamlab,項目名稱:Versioned-API-Tuto,代碼行數:19,代碼來源:UserTransformer.php

示例9: sendResettingEmailMessage

 /**
  * @param User $user
  */
 public function sendResettingEmailMessage(User $user)
 {
     /* Variables used in template */
     $confirmationToken = $user->getConfirmationToken();
     $username = $user->getUsername();
     /* END */
     /* Variables used in mail sending function */
     $subject = 'Resetowanie hasła';
     $email = $user->getEmail();
     $renderedTemplate = $this->templating->render('AppBundle:Emails:passwordResetting.html.twig', array('username' => $username, 'confirmationToken' => $confirmationToken));
     /* END */
     $this->sendEmailMessage($renderedTemplate, $subject, $email);
 }
開發者ID:bamper,項目名稱:application,代碼行數:16,代碼來源:Mailer.php

示例10: __construct

 /**
  * UserModel constructor.
  * @param User $user
  */
 public function __construct(User $user)
 {
     $this->setId($user->getId());
     $this->setUsername($user->getUsername());
     $this->setUserFirstName($user->getUserFirstName());
     $this->setUserLastName($user->getUserLastName());
     $this->setEmail($user->getEmail());
     $this->setPassword($user->getPassword());
     $this->setApiKey($user->getApiKey());
     $role = $this->determineTheBiggestRole($user);
     if ($role) {
         $this->setRole(new RoleModel($role));
     }
 }
開發者ID:Gardax,項目名稱:studentsSystem,代碼行數:18,代碼來源:UserModel.php

示例11: uploadUserAvatar

 public function uploadUserAvatar(User $user)
 {
     /**
      * @var UploadedFile $file
      */
     $file = $user->getAvatarUrl();
     if ($file != null) {
         $username = trim($user->getUsername());
         $username = preg_replace('/\\s+/', '_', $username);
         $fileName = $username . '_avatar.' . $file->guessExtension();
         $avatarsDir = $this->kernelRootDir . '' . self::USER_AVATAR_DIR;
         $file->move($avatarsDir, $fileName);
         $user->setAvatarUrl($fileName);
     }
 }
開發者ID:redaLaanait,項目名稱:SYMF_MOCK,代碼行數:15,代碼來源:UserService.php

示例12: product_detail

 /**
  * 客戶產品詳情
  * @Route("/product_detail/{id}", name="productdetail")
  * @Method({"GET","POST"})
  * @ParamConverter("user", class="AppBundle:User")
  */
 public function product_detail($id, User $user)
 {
     $em = $this->getDoctrine()->getManager();
     //get stock data of user
     $stock_data = $em->getRepository('AppBundle:Stock')->findBy(array('user' => $id));
     $sum = 0;
     foreach ($stock_data as $value) {
         $sum += $value->calculateProfitAndLoss();
     }
     //get insurance data of user
     $insurance_stock = $em->getRepository('AppBundle:Insurance')->findBy(array('user' => $id));
     //get name of current user
     $username = $user->getUsername();
     //create upload form
     $upload_form = $this->createUploadForm($user);
     return $this->render('FOSUserBundle:Clients:products_detail.html.twig', array('stock_data' => $stock_data, 'insurance_data' => $insurance_stock, 'username' => $username, 'sum' => $sum, 'user_id' => $id, 'upload_form' => $upload_form->createView()));
 }
開發者ID:neteasy-work,項目名稱:hkgbf_crm,代碼行數:23,代碼來源:ClientsProductController.php

示例13: test_create_token

 public function test_create_token()
 {
     $user = new User();
     $user->setId(1);
     $user->setUsername('user1');
     $signer = new Sha256();
     $secret = 'test_sign_secret';
     $config = ['issuer' => 'me', 'audience' => 'me', 'appid' => 10, 'expire' => 60, 'notbefore' => 5];
     $issued = Carbon::now();
     $expire = Carbon::now()->addSeconds((int) $config['expire']);
     $notBefore = Carbon::now()->addSeconds((int) $config['notbefore']);
     $builder = $this->prophesize(Builder::class);
     $builder->setIssuer('me')->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->setAudience('me')->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->setId(10, true)->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->setIssuedAt($issued->getTimestamp())->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->setNotBefore($notBefore->getTimestamp())->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->setExpiration($expire->getTimestamp())->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->set('data', ["uid" => $user->getId(), "uidentifier" => $user->getUsername()])->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->sign($signer, $secret)->shouldBeCalledTimes(1)->willReturn($builder->reveal());
     $builder->getToken()->shouldBeCalledTimes(1)->willReturn(new Token());
     $generator = new TokenGenerator($builder->reveal(), $signer, $secret, $config);
     $generator->createToken($user);
 }
開發者ID:Algatux,項目名稱:symfony3.0,代碼行數:24,代碼來源:TokenGeneratorTest.php

示例14: setUser

 /**
  * @param User $user
  */
 public function setUser(User $user)
 {
     $this->user = $user;
     $this->username = $user->getUsername();
 }
開發者ID:amm0nite,項目名稱:shared-budget,代碼行數:8,代碼來源:Action.php

示例15: fromUser

 public function fromUser(User $user)
 {
     $userContract = new self();
     //Force fetch
     $user->getMyContacts()->toArray();
     $user->getConversations()->toArray();
     $user->getContactsWithMe()->toArray();
     $userContract->id = $user->getId();
     $userContract->tkey = $user->getTkey();
     $userContract->avatar = $user->getAvatar();
     $userContract->birthday = $user->getBirthday();
     $userContract->cdate = $user->getCdate();
     $userContract->conversations = $user->getConversations();
     $userContract->connections = $user->getConnections();
     $userContract->contactsphones = $user->getContactsphones();
     $userContract->email = $user->getEmail();
     $userContract->fname = $user->getFname();
     $userContract->lastUpdate = $user->getLastUpdate();
     $userContract->lname = $user->getLname();
     $userContract->contactsWithMe = $user->getContactsWithMe();
     $user->getMyContacts()->toArray();
     $userContract->myContacts = $user->getMyContacts();
     $userContract->password = $user->getPassword();
     $userContract->phone = $user->getPhone();
     $userContract->username = $user->getUsername();
     return $userContract;
 }
開發者ID:jparaskakis,項目名稱:thesis_back,代碼行數:27,代碼來源:UserContract.php


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