当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setPhoto方法代码示例

本文整理汇总了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()));
     }
 }
开发者ID:sghribi,项目名称:garopi,代码行数:16,代码来源:UserService.php

示例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();
     }
 }
开发者ID:nebs-dev,项目名称:tts,代码行数:46,代码来源:UserService.php

示例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);
 }
开发者ID:gototog,项目名称:api-catwomap,代码行数:24,代码来源:CrudUserService.php


注:本文中的AppBundle\Entity\User::setPhoto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。