本文整理汇总了PHP中AppBundle\Entity\User::setPhoto方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPhoto方法的具体用法?PHP User::setPhoto怎么用?PHP User::setPhoto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::setPhoto方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: loginTwitter
/**
* Login user with twitterId
* @param $request
* @return bool
*/
public function loginTwitter($request)
{
$twitterId = $request->request->get('user_id');
$name = $request->request->get('name');
$photo = $request->request->get('picture_url');
$platform = $request->request->get('platform');
try {
// If user exists
if ($twitterId && ($user = $this->em->getRepository('AppBundle:User')->findOneByTwitterId($twitterId))) {
$user->setTwitterId($twitterId);
if (isset($name)) {
$user->setName($name);
}
$user->setPlatform($platform);
$user->setPhoto($photo);
$this->em->persist($user);
$this->em->flush();
// New twitter user
} else {
$user = new User();
$user->setPlatform($platform);
$user->setPhoto($photo);
$user->setTwitterId($twitterId);
if (isset($name)) {
$user->setName($name);
}
$token = $request->request->get('token');
if (!$token) {
$random = substr(md5(rand()), 0, 7);
$newToken = sha1('MIDGET' . $random . 'NINJA');
$user->setToken($newToken);
}
$this->em->persist($user);
$this->em->flush();
}
$user = $this->em->getRepository('AppBundle:User')->getOneByToken($user->getToken());
return $user;
} catch (\ExportException $e) {
return $e->getMessage();
}
}
示例3: createUser
/**
* @param User $user
*
* @return UserDTO
*/
public function createUser(User $user)
{
if ($user->getPositionLat() . $user->getPositionLong() != "") {
$infos = Geocoder::getLocation($user->getPositionLat(), $user->getPositionLong());
$city = Geocoder::getCityFromAddress($infos);
$department = Geocoder::getDepartmentFromAddress($infos);
$country = Geocoder::getCountryFromAddress($infos);
$user->setPositionCity($city);
$user->setPositionDep($department);
$user->setPositionCountry($country);
}
$user->setPassword(sha1($user->getPassword()));
if ($user->getPhoto() == "") {
$user->setPhoto("https://randomuser.me/api/portraits/med/men/54.jpg");
}
$this->em->persist($user);
$this->em->flush();
return new UserDTO($user);
}