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


PHP User::setAvatarUrl方法代碼示例

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


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

示例1: __construct

 public function __construct()
 {
     $user = new User();
     $user->setId("1");
     $user->setUsername("test");
     $user->setEmail('test@test.test');
     $user->setPassword("pass");
     $user->setAvatarUrl("default_avatar.jpg");
     $this->user = $user;
 }
開發者ID:redaLaanait,項目名稱:SYMF_MOCK,代碼行數:10,代碼來源:UserServiceMock.php

示例2: load

 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('admin');
     $user->setPassword('$2a$08$jHZj/wJfcVKlIwr5AvR78euJxYK7Ku5kURNhNx.7.CSIJ3Pq6LEPC');
     $user->setEmail("test@test.com");
     $user->setAvatarUrl("default_avatar.jpg");
     $manager->persist($user);
     $manager->flush();
 }
開發者ID:redaLaanait,項目名稱:SYMF_MOCK,代碼行數:10,代碼來源:LoadUserData.php

示例3: 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

示例4: testUpdateUser

 public function testUpdateUser()
 {
     $user = new User();
     $user->setUsername("user1");
     $user->setPassword("\$2y\$13\$9z7J/8pHLBd4OC7sJQZiFe.C79rBWzByn0Z9V4Viu5hESJ2E4cvj2");
     $user->setEmail("username1@test.com");
     $user->setAvatarUrl("user3_avatar.jpg");
     $this->em->persist($user);
     // Not using createUser from our repository, not safe
     $this->em->flush();
     $newUser = $this->repository->find($user->getId());
     $newUsername = "newUsername";
     $newUser->setUsername($newUsername);
     $this->repository->updateUser($newUser);
     $updatedUser = $this->repository->find($newUser->getId());
     $this->assertNotNull($updatedUser);
     $this->assertEquals($updatedUser->getId(), $newUser->getId());
     $this->assertEquals($updatedUser->getUsername(), $newUser->getUsername());
     $this->assertEquals($updatedUser->getEmail(), $newUser->getEmail());
     $this->assertEquals($updatedUser->getPassword(), $newUser->getPassword());
     // TODO find a way to compare two objects
 }
開發者ID:redaLaanait,項目名稱:SYMF_MOCK,代碼行數:22,代碼來源:UserRepositoryTest.php


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