當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::fromArray方法代碼示例

本文整理匯總了PHP中models\User::fromArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::fromArray方法的具體用法?PHP User::fromArray怎麽用?PHP User::fromArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models\User的用法示例。


在下文中一共展示了User::fromArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 protected function create()
 {
     $params = arrayKeysSnakeToCamel($_POST['user']);
     $user = new User();
     $user->fromArray($params);
     $user->save();
     $this->addFlash("success", "registered");
     redirectTo("/");
 }
開發者ID:OneTimeCZ,項目名稱:Tasker,代碼行數:9,代碼來源:UserController.php

示例2: create

 protected function create()
 {
     if (isset($_POST["email"]) && isset($_POST["username"]) && isset($_POST["password"])) {
         $user = new User();
         $emailConfirmToken = uniqid() . generateRandomString(19);
         $user->fromArray(array("Email" => $_POST["email"], "Username" => $_POST["username"], "Password" => $_POST["password"], "EmailConfirmToken" => $emailConfirmToken));
         if (!$user->save()) {
             $failures = $user->getValidationFailures();
             if (count($failures) > 0) {
                 foreach ($failures as $failure) {
                     $this->sendFlashMessage("You have not been signed up. " . $failure->getMessage(), "error");
                 }
             }
         } else {
             $this->sendFlashMessage('You have been successfuly signed up. Please confirm your email address, we have send confirmation link. <a class="link" href="/user/' . $user->getUsername() . '/send-email-confirm-email">Send new email confirm link?</a>', "success");
             $body = '<p>You have created new account on Starling.</p><br /><p>Please virify your email address by clicking this url:</p><a href="' . $this->siteURL . '/user/' . $user->getUsername() . '/email-confirm/' . urlencode($emailConfirmToken) . '">' . $this->siteURL . '/user/' . $user->getUsername() . '/email-confirm/' . urlencode($emailConfirmToken) . '</a>';
             $transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($this->emailAddress)->setPassword($this->emailPassword);
             $mailer = \Swift_Mailer::newInstance($transport);
             $message = \Swift_Message::newInstance()->setSubject('Email verification')->setFrom(array($this->emailAddress => 'Starling admin'))->setTo(array($user->getEmail() => $user->getUsername()))->setBody($body, 'text/html');
             $result = $mailer->send($message);
         }
         $this->redirect("/");
     } else {
         setHTTPStatusCode("400");
     }
 }
開發者ID:xfreddiex,項目名稱:code-sharer,代碼行數:26,代碼來源:UserController.php


注:本文中的models\User::fromArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。