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


PHP PhabricatorUser::setPHID方法代码示例

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


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

示例3: buildUser

 /**
  * Build a test user to spec.
  */
 private function buildUser($spec)
 {
     $user = new PhabricatorUser();
     switch ($spec) {
         case 'public':
             break;
         case 'user':
             $user->setPHID(1);
             break;
         case 'admin':
             $user->setPHID(1);
             $user->setIsAdmin(true);
             break;
         default:
             throw new Exception("Unknown user spec '{$spec}'.");
     }
     return $user;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:21,代码来源:PhabricatorPolicyTestCase.php


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