本文整理汇总了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;
}
示例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();
}
示例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);
}
}
示例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
}