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


PHP PhabricatorUser::setID方法代码示例

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


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

示例1: createNewUser

 /**
  * @task edit
  */
 public function createNewUser(PhabricatorUser $user, PhabricatorUserEmail $email)
 {
     if ($user->getID()) {
         throw new Exception("User has already been created!");
     }
     if ($email->getID()) {
         throw new Exception("Email has already been created!");
     }
     if (!PhabricatorUser::validateUsername($user->getUsername())) {
         $valid = PhabricatorUser::describeValidUsername();
         throw new Exception("Username is invalid! {$valid}");
     }
     // Always set a new user's email address to primary.
     $email->setIsPrimary(1);
     $this->willAddEmail($email);
     $user->openTransaction();
     try {
         $user->save();
         $email->setUserPHID($user->getPHID());
         $email->save();
     } catch (AphrontQueryDuplicateKeyException $ex) {
         // We might have written the user but failed to write the email; if
         // so, erase the IDs we attached.
         $user->setID(null);
         $user->setPHID(null);
         $user->killTransaction();
         throw $ex;
     }
     $log = PhabricatorUserLog::newLog($this->actor, $user, PhabricatorUserLog::ACTION_CREATE);
     $log->setNewValue($email->getAddress());
     $log->save();
     $user->saveTransaction();
     return $this;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:37,代码来源:PhabricatorUserEditor.php

示例2: createNewUser

 /**
  * @task edit
  */
 public function createNewUser(PhabricatorUser $user, PhabricatorUserEmail $email, $allow_reassign = false)
 {
     if ($user->getID()) {
         throw new Exception(pht('User has already been created!'));
     }
     $is_reassign = false;
     if ($email->getID()) {
         if ($allow_reassign) {
             if ($email->getIsPrimary()) {
                 throw new Exception(pht('Primary email addresses can not be reassigned.'));
             }
             $is_reassign = true;
         } else {
             throw new Exception(pht('Email has already been created!'));
         }
     }
     if (!PhabricatorUser::validateUsername($user->getUsername())) {
         $valid = PhabricatorUser::describeValidUsername();
         throw new Exception(pht('Username is invalid! %s', $valid));
     }
     // Always set a new user's email address to primary.
     $email->setIsPrimary(1);
     // If the primary address is already verified, also set the verified flag
     // on the user themselves.
     if ($email->getIsVerified()) {
         $user->setIsEmailVerified(1);
     }
     $this->willAddEmail($email);
     $user->openTransaction();
     try {
         $user->save();
         $email->setUserPHID($user->getPHID());
         $email->save();
     } catch (AphrontDuplicateKeyQueryException $ex) {
         // We might have written the user but failed to write the email; if
         // so, erase the IDs we attached.
         $user->setID(null);
         $user->setPHID(null);
         $user->killTransaction();
         throw $ex;
     }
     $log = PhabricatorUserLog::initializeNewLog($this->requireActor(), $user->getPHID(), PhabricatorUserLog::ACTION_CREATE);
     $log->setNewValue($email->getAddress());
     $log->save();
     if ($is_reassign) {
         $log = PhabricatorUserLog::initializeNewLog($this->requireActor(), $user->getPHID(), PhabricatorUserLog::ACTION_EMAIL_REASSIGN);
         $log->setNewValue($email->getAddress());
         $log->save();
     }
     $user->saveTransaction();
     if ($email->getIsVerified()) {
         $this->didVerifyEmail($user, $email);
     }
     return $this;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:58,代码来源:PhabricatorUserEditor.php


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