当前位置: 首页>>代码示例>>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;未经允许,请勿转载。