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


PHP User::setEmail方法代码示例

本文整理汇总了PHP中Model\User::setEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setEmail方法的具体用法?PHP User::setEmail怎么用?PHP User::setEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model\User的用法示例。


在下文中一共展示了User::setEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertUpdateProcessing

 public function insertUpdateProcessing($em, $passwordEncoder, $data, $id)
 {
     $update = !is_null($id);
     try {
         $em->beginTransaction();
         if ($update) {
             $user = $em->find('Model\\User', $id);
         } else {
             $user = new User();
         }
         $user->setUsername($data['username']);
         //Regenerate salt and update password only if a new password is provided
         if (isset($data['password']) && strlen($data['password']) > 8 && strlen($data['password']) < 1024) {
             //Prepare salt
             //                $salt = base64_encode(mcrypt_create_iv(ceil(0.75 * 32), MCRYPT_DEV_URANDOM));
             $salt = uniqid("", true);
             $user->setSalt($salt);
             //Encrypt password
             $password = $passwordEncoder->encodePassword($data['password'], $user->getSalt());
             $user->setPassword($password);
         }
         $user->setName($data['name']);
         $user->setSurname($data['surname']);
         $user->setEmail($data['email']);
         $user->setPhone($data['phone']);
         $user->setAddress($data['address']);
         $user->setCap($data['cap']);
         $user->setCity($data['city']);
         $user->setProvince($data['province']);
         $user->setCountry($data['country']);
         //Prepare roles string
         $roles = array();
         if (isset($data['roles'])) {
             foreach ($data['roles'] as $roleString => $val) {
                 $roles[] = new Role($roleString);
             }
         }
         $user->setRoles($roles);
         //Prepare accountExpiration DateTime object
         $accountExpiration = new \DateTime($data['accountExpiration'], new \DateTimeZone('Europe/Rome'));
         $user->setAccountExpiration($accountExpiration);
         $enabled = isset($data['enabled']);
         $user->setEnabled($enabled);
         //Prepare credentialsExpiration DateTime object
         $credentialsExpiration = new \DateTime($data['credentialsExpiration'], new \DateTimeZone('Europe/Rome'));
         $user->setCredentialsExpiration($credentialsExpiration);
         if ($update) {
             $em->merge($user);
         } else {
             $em->persist($user);
         }
         $em->flush();
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $user->getId();
 }
开发者ID:francescocambi,项目名称:FCMS2,代码行数:59,代码来源:EditorController.php

示例2: registerUser

 public function registerUser()
 {
     $user = new User();
     $user->setEmail($this->request_body->email);
     $user->setPassword(md5($this->request_body->password));
     $user->save();
     $token = new AccessToken();
     $token->setTokenContent(uniqid());
     $token->setUser($user);
     $token->save();
     return array('user' => $user->toArray(), 'token' => $token->toArray());
 }
开发者ID:hackathon-5,项目名称:power-ragers-repo,代码行数:12,代码来源:UserController.php


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