本文整理汇总了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()));
}
}
示例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();
}
示例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()));
}
示例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();
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
示例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));
}
}
示例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);
}
}
示例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()));
}
示例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);
}
示例14: setUser
/**
* @param User $user
*/
public function setUser(User $user)
{
$this->user = $user;
$this->username = $user->getUsername();
}
示例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;
}