當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。