• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PhutilEventEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $phids = $request->getArr('phids');
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     $objects = id(new PhabricatorObjectQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     $cards = array();
     foreach ($phids as $phid) {
         $handle = $handles[$phid];
         $object = $objects[$phid];
         $hovercard = id(new PhabricatorHovercardView())->setUser($viewer)->setObjectHandle($handle);
         if ($object) {
             $hovercard->setObject($object);
         }
         // Send it to the other side of the world, thanks to PhutilEventEngine
         $event = new PhabricatorEvent(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD, array('hovercard' => $hovercard, 'handle' => $handle, 'object' => $object));
         $event->setUser($viewer);
         PhutilEventEngine::dispatchEvent($event);
         $cards[$phid] = $hovercard;
     }
     // Browser-friendly for non-Ajax requests
     if (!$request->isAjax()) {
         foreach ($cards as $key => $hovercard) {
             $cards[$key] = phutil_tag('div', array('class' => 'ml'), $hovercard);
         }
         return $this->buildApplicationPage($cards, array('device' => false));
     } else {
         return id(new AphrontAjaxResponse())->setContent(array('cards' => $cards));
     }
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:30,代码来源:PhabricatorSearchHovercardController.php


示例2: getInstance

 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new PhutilEventEngine();
     }
     return self::$instance;
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:7,代码来源:PhutilEventEngine.php


示例3: fireLookupEvent

 /**
  * Emit an event so installs can do custom lookup of commit authors who may
  * not be naturally resolvable.
  */
 private function fireLookupEvent($guess)
 {
     $type = PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER;
     $data = array('commit' => $this->commit, 'query' => $this->name, 'result' => $guess);
     $event = new PhabricatorEvent($type, $data);
     PhutilEventEngine::dispatchEvent($event);
     return $event->getValue('result');
 }
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:DiffusionResolveUserQuery.php


示例4: invokeWillRenderEvent

 public function invokeWillRenderEvent()
 {
     if ($this->object && $this->getUser() && !$this->invokedWillRenderEvent) {
         $event = new PhabricatorEvent(PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES, array('object' => $this->object, 'view' => $this));
         $event->setUser($this->getUser());
         PhutilEventEngine::dispatchEvent($event);
     }
     $this->invokedWillRenderEvent = true;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:PHUIPropertyListView.php


示例5: willBeginExecution

 public final function willBeginExecution()
 {
     $request = $this->getRequest();
     $user = new PhabricatorUser();
     $phusr = $request->getCookie('phusr');
     $phsid = $request->getCookie('phsid');
     if (strlen($phusr) && $phsid) {
         $info = queryfx_one($user->establishConnection('r'), 'SELECT u.* FROM %T u JOIN %T s ON u.phid = s.userPHID
       AND s.type LIKE %> AND s.sessionKey = %s', $user->getTableName(), 'phabricator_session', 'web-', $phsid);
         if ($info) {
             $user->loadFromArray($info);
         }
     }
     $translation = $user->getTranslation();
     if ($translation && $translation != PhabricatorEnv::getEnvConfig('translation.provider')) {
         $translation = newv($translation, array());
         PhutilTranslator::getInstance()->setLanguage($translation->getLanguage())->addTranslations($translation->getTranslations());
     }
     $request->setUser($user);
     if ($user->getIsDisabled() && $this->shouldRequireEnabledUser()) {
         $disabled_user_controller = new PhabricatorDisabledUserController($request);
         return $this->delegateToController($disabled_user_controller);
     }
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_CONTROLLER_CHECKREQUEST, array('request' => $request, 'controller' => get_class($this)));
     $event->setUser($user);
     PhutilEventEngine::dispatchEvent($event);
     $checker_controller = $event->getValue('controller');
     if ($checker_controller != get_class($this)) {
         return $this->delegateToController($checker_controller);
     }
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
         if ($user->getConsoleEnabled() || PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
             $console = new DarkConsoleCore();
             $request->getApplicationConfiguration()->setConsole($console);
         }
     }
     if ($this->shouldRequireLogin() && !$user->getPHID()) {
         $login_controller = new PhabricatorLoginController($request);
         return $this->delegateToController($login_controller);
     }
     if ($this->shouldRequireEmailVerification()) {
         $email = $user->loadPrimaryEmail();
         if (!$email) {
             throw new Exception("No primary email address associated with this account!");
         }
         if (!$email->getIsVerified()) {
             $verify_controller = new PhabricatorMustVerifyEmailController($request);
             return $this->delegateToController($verify_controller);
         }
     }
     if ($this->shouldRequireAdmin() && !$user->getIsAdmin()) {
         return new Aphront403Response();
     }
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:54,代码来源:PhabricatorController.php


示例6: generateData

 public function generateData()
 {
     $listeners = PhutilEventEngine::getInstance()->getAllListeners();
     foreach ($listeners as $key => $listener) {
         $listeners[$key] = array('id' => $listener->getListenerID(), 'class' => get_class($listener));
     }
     $events = DarkConsoleEventPluginAPI::getEvents();
     foreach ($events as $key => $event) {
         $events[$key] = array('type' => $event->getType(), 'stopped' => $event->isStopped());
     }
     return array('listeners' => $listeners, 'events' => $events);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:12,代码来源:DarkConsoleEventPlugin.php


示例7: render

 public function render()
 {
     if (!$this->user) {
         throw new Exception("Call setUser() before render()!");
     }
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS, array('object' => $this->object, 'actions' => $this->actions));
     $event->setUser($this->user);
     PhutilEventEngine::dispatchEvent($event);
     $actions = $event->getValue('actions');
     if (!$actions) {
         return null;
     }
     require_celerity_resource('phabricator-action-list-view-css');
     return phutil_render_tag('ul', array('class' => 'phabricator-action-list-view'), $this->renderSingleView($actions));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:15,代码来源:PhabricatorActionListView.php


示例8: render

 public function render()
 {
     $viewer = $this->getViewer();
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS, array('object' => $this->object, 'actions' => $this->actions));
     $event->setUser($viewer);
     PhutilEventEngine::dispatchEvent($event);
     $actions = $event->getValue('actions');
     if (!$actions) {
         return null;
     }
     foreach ($actions as $action) {
         $action->setViewer($viewer);
     }
     require_celerity_resource('phabricator-action-list-view-css');
     return phutil_tag('ul', array('class' => 'phabricator-action-list-view', 'id' => $this->id), $actions);
 }
开发者ID:vinzent,项目名称:phabricator,代码行数:16,代码来源:PhabricatorActionListView.php


示例9: loginUser

 /**
  * Log a user into a web session and return an @{class:AphrontResponse} which
  * corresponds to continuing the login process.
  *
  * Normally, this is a redirect to the validation controller which makes sure
  * the user's cookies are set. However, event listeners can intercept this
  * event and do something else if they prefer.
  *
  * @param   PhabricatorUser   User to log the viewer in as.
  * @return  AphrontResponse   Response which continues the login process.
  */
 protected function loginUser(PhabricatorUser $user)
 {
     $response = $this->buildLoginValidateResponse($user);
     $session_type = PhabricatorAuthSession::TYPE_WEB;
     $event_type = PhabricatorEventType::TYPE_AUTH_WILLLOGINUSER;
     $event_data = array('user' => $user, 'type' => $session_type, 'response' => $response, 'shouldLogin' => true);
     $event = id(new PhabricatorEvent($event_type, $event_data))->setUser($user);
     PhutilEventEngine::dispatchEvent($event);
     $should_login = $event->getValue('shouldLogin');
     if ($should_login) {
         $session_key = id(new PhabricatorAuthSessionEngine())->establishSession($session_type, $user->getPHID(), $partial = true);
         // NOTE: We allow disabled users to login and roadblock them later, so
         // there's no check for users being disabled here.
         $request = $this->getRequest();
         $request->setCookie(PhabricatorCookies::COOKIE_USERNAME, $user->getUsername());
         $request->setCookie(PhabricatorCookies::COOKIE_SESSION, $session_key);
         $this->clearRegistrationCookies();
     }
     return $event->getValue('response');
 }
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:PhabricatorAuthController.php


示例10: phutil_exit

 /**
  * Fire an event allowing any listeners to clear up any outstanding requirements
  * before the request completes abruptly.
  *
  * @param int|string $status
  * @group library
  */
 public function phutil_exit($status = 0)
 {
     $event = new PhutilEvent(PhutilEventType::TYPE_WILLEXITABRUPTLY, array("status" => $status));
     PhutilEventEngine::dispatchEvent($event);
     exit($status);
 }
开发者ID:hazbo,项目名称:futures,代码行数:13,代码来源:Utils.php


示例11: send

 public function send()
 {
     $to_phids = $this->getToPHIDs();
     if (!$to_phids) {
         throw new Exception('No "To:" users provided!');
     }
     $cc_phids = $this->getCCPHIDs();
     $subject = $this->buildSubject();
     $body = $this->buildBody();
     $attachments = $this->buildAttachments();
     $template = new PhabricatorMetaMTAMail();
     $actor_handle = $this->getActorHandle();
     $reply_handler = $this->getReplyHandler();
     if ($actor_handle) {
         $template->setFrom($actor_handle->getPHID());
     }
     $template->setSubject($subject)->setBody($body)->setIsHTML($this->shouldMarkMailAsHTML())->setParentMessageID($this->parentMessageID)->addHeader('Thread-Topic', $this->getRevision()->getTitle());
     $template->setAttachments($attachments);
     $template->setThreadID($this->getThreadID(), $this->isFirstMailAboutRevision());
     if ($this->heraldRulesHeader) {
         $template->addHeader('X-Herald-Rules', $this->heraldRulesHeader);
     }
     $template->setIsBulk(true);
     $template->setRelatedPHID($this->getRevision()->getPHID());
     $phids = array();
     foreach ($to_phids as $phid) {
         $phids[$phid] = true;
     }
     foreach ($cc_phids as $phid) {
         $phids[$phid] = true;
     }
     $phids = array_keys($phids);
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_DIFFERENTIAL_WILLSENDMAIL, array('mail' => $template));
     PhutilEventEngine::dispatchEvent($event);
     $template = $event->getValue('mail');
     $mails = $reply_handler->multiplexMail($template, array_select_keys($handles, $to_phids), array_select_keys($handles, $cc_phids));
     foreach ($mails as $mail) {
         $mail->saveAndSend();
     }
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:41,代码来源:DifferentialMail.php


示例12: recordCommit

 private function recordCommit(PhabricatorRepository $repository, $commit_identifier, $epoch, $close_immediately, array $parents)
 {
     $commit = new PhabricatorRepositoryCommit();
     $conn_w = $repository->establishConnection('w');
     // First, try to revive an existing unreachable commit (if one exists) by
     // removing the "unreachable" flag. If we succeed, we don't need to do
     // anything else: we already discovered this commit some time ago.
     queryfx($conn_w, 'UPDATE %T SET importStatus = (importStatus & ~%d)
     WHERE repositoryID = %d AND commitIdentifier = %s', $commit->getTableName(), PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE, $repository->getID(), $commit_identifier);
     if ($conn_w->getAffectedRows()) {
         $commit = $commit->loadOneWhere('repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $commit_identifier);
         // After reviving a commit, schedule new daemons for it.
         $this->didDiscoverCommit($repository, $commit, $epoch);
         return;
     }
     $commit->setRepositoryID($repository->getID());
     $commit->setCommitIdentifier($commit_identifier);
     $commit->setEpoch($epoch);
     if ($close_immediately) {
         $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE);
     }
     $data = new PhabricatorRepositoryCommitData();
     try {
         // If this commit has parents, look up their IDs. The parent commits
         // should always exist already.
         $parent_ids = array();
         if ($parents) {
             $parent_rows = queryfx_all($conn_w, 'SELECT id, commitIdentifier FROM %T
         WHERE commitIdentifier IN (%Ls) AND repositoryID = %d', $commit->getTableName(), $parents, $repository->getID());
             $parent_map = ipull($parent_rows, 'id', 'commitIdentifier');
             foreach ($parents as $parent) {
                 if (empty($parent_map[$parent])) {
                     throw new Exception(pht('Unable to identify parent "%s"!', $parent));
                 }
                 $parent_ids[] = $parent_map[$parent];
             }
         } else {
             // Write an explicit 0 so we can distinguish between "really no
             // parents" and "data not available".
             if (!$repository->isSVN()) {
                 $parent_ids = array(0);
             }
         }
         $commit->openTransaction();
         $commit->save();
         $data->setCommitID($commit->getID());
         $data->save();
         foreach ($parent_ids as $parent_id) {
             queryfx($conn_w, 'INSERT IGNORE INTO %T (childCommitID, parentCommitID)
           VALUES (%d, %d)', PhabricatorRepository::TABLE_PARENTS, $commit->getID(), $parent_id);
         }
         $commit->saveTransaction();
         $this->didDiscoverCommit($repository, $commit, $epoch);
         if ($this->repairMode) {
             // Normally, the query should throw a duplicate key exception. If we
             // reach this in repair mode, we've actually performed a repair.
             $this->log(pht('Repaired commit "%s".', $commit_identifier));
         }
         PhutilEventEngine::dispatchEvent(new PhabricatorEvent(PhabricatorEventType::TYPE_DIFFUSION_DIDDISCOVERCOMMIT, array('repository' => $repository, 'commit' => $commit)));
     } catch (AphrontDuplicateKeyQueryException $ex) {
         $commit->killTransaction();
         // Ignore. This can happen because we discover the same new commit
         // more than once when looking at history, or because of races or
         // data inconsistency or cosmic radiation; in any case, we're still
         // in a good state if we ignore the failure.
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:67,代码来源:PhabricatorRepositoryDiscoveryEngine.php


示例13: recordCommit

 private function recordCommit(PhabricatorRepository $repository, $commit_identifier, $epoch, $close_immediately, array $parents)
 {
     $commit = new PhabricatorRepositoryCommit();
     $commit->setRepositoryID($repository->getID());
     $commit->setCommitIdentifier($commit_identifier);
     $commit->setEpoch($epoch);
     if ($close_immediately) {
         $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE);
     }
     $data = new PhabricatorRepositoryCommitData();
     $conn_w = $repository->establishConnection('w');
     try {
         // If this commit has parents, look up their IDs. The parent commits
         // should always exist already.
         $parent_ids = array();
         if ($parents) {
             $parent_rows = queryfx_all($conn_w, 'SELECT id, commitIdentifier FROM %T
         WHERE commitIdentifier IN (%Ls) AND repositoryID = %d', $commit->getTableName(), $parents, $repository->getID());
             $parent_map = ipull($parent_rows, 'id', 'commitIdentifier');
             foreach ($parents as $parent) {
                 if (empty($parent_map[$parent])) {
                     throw new Exception(pht('Unable to identify parent "%s"!', $parent));
                 }
                 $parent_ids[] = $parent_map[$parent];
             }
         } else {
             // Write an explicit 0 so we can distinguish between "really no
             // parents" and "data not available".
             if (!$repository->isSVN()) {
                 $parent_ids = array(0);
             }
         }
         $commit->openTransaction();
         $commit->save();
         $data->setCommitID($commit->getID());
         $data->save();
         foreach ($parent_ids as $parent_id) {
             queryfx($conn_w, 'INSERT IGNORE INTO %T (childCommitID, parentCommitID)
           VALUES (%d, %d)', PhabricatorRepository::TABLE_PARENTS, $commit->getID(), $parent_id);
         }
         $commit->saveTransaction();
         $this->insertTask($repository, $commit);
         queryfx($conn_w, 'INSERT INTO %T (repositoryID, size, lastCommitID, epoch)
       VALUES (%d, 1, %d, %d)
       ON DUPLICATE KEY UPDATE
         size = size + 1,
         lastCommitID =
           IF(VALUES(epoch) > epoch, VALUES(lastCommitID), lastCommitID),
         epoch = IF(VALUES(epoch) > epoch, VALUES(epoch), epoch)', PhabricatorRepository::TABLE_SUMMARY, $repository->getID(), $commit->getID(), $epoch);
         if ($this->repairMode) {
             // Normally, the query should throw a duplicate key exception. If we
             // reach this in repair mode, we've actually performed a repair.
             $this->log(pht('Repaired commit "%s".', $commit_identifier));
         }
         PhutilEventEngine::dispatchEvent(new PhabricatorEvent(PhabricatorEventType::TYPE_DIFFUSION_DIDDISCOVERCOMMIT, array('repository' => $repository, 'commit' => $commit)));
     } catch (AphrontDuplicateKeyQueryException $ex) {
         $commit->killTransaction();
         // Ignore. This can happen because we discover the same new commit
         // more than once when looking at history, or because of races or
         // data inconsistency or cosmic radiation; in any case, we're still
         // in a good state if we ignore the failure.
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:63,代码来源:PhabricatorRepositoryDiscoveryEngine.php


示例14: lookupUser

 /**
  * Emit an event so installs can do custom lookup of commit authors who may
  * not be naturally resolvable.
  */
 private function lookupUser(PhabricatorRepositoryCommit $commit, $query, $guess)
 {
     $type = PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER;
     $data = array('commit' => $commit, 'query' => $query, 'result' => $guess);
     $event = new PhabricatorEvent($type, $data);
     PhutilEventEngine::dispatchEvent($event);
     return $event->getValue('result');
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:12,代码来源:PhabricatorRepositoryCommitMessageParserWorker.php


示例15: processRequest


//.........这里部分代码省略.........
                 $transaction->setTransactionType($type);
                 if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) {
                     $transaction->setNewValue($value['new']);
                     $transaction->setOldValue($value['old']);
                 } else {
                     if ($type == ManiphestTransaction::TYPE_PROJECTS) {
                         // TODO: Gross.
                         $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
                         $transaction->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $project_type)->setNewValue(array('=' => array_fuse($value)));
                     } else {
                         $transaction->setNewValue($value);
                     }
                 }
                 $transactions[] = $transaction;
             }
             if ($aux_fields) {
                 foreach ($aux_fields as $aux_field) {
                     $transaction = clone $template;
                     $transaction->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD);
                     $aux_key = $aux_field->getFieldKey();
                     $transaction->setMetadataValue('customfield:key', $aux_key);
                     $old = idx($old_values, $aux_key);
                     $new = $aux_field->getNewValueForApplicationTransactions();
                     $transaction->setOldValue($old);
                     $transaction->setNewValue($new);
                     $transactions[] = $transaction;
                 }
             }
             if ($transactions) {
                 $is_new = !$task->getID();
                 $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
                 $event->setUser($user);
                 $event->setAphrontRequest($request);
                 PhutilEventEngine::dispatchEvent($event);
                 $task = $event->getValue('task');
                 $transactions = $event->getValue('transactions');
                 $editor = id(new ManiphestTransactionEditor())->setActor($user)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->applyTransactions($task, $transactions);
                 $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
                 $event->setUser($user);
                 $event->setAphrontRequest($request);
                 PhutilEventEngine::dispatchEvent($event);
             }
             if ($parent_task) {
                 // TODO: This should be transactional now.
                 id(new PhabricatorEdgeEditor())->addEdge($parent_task->getPHID(), PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, $task->getPHID())->save();
                 $workflow = $parent_task->getID();
             }
             if ($request->isAjax()) {
                 switch ($response_type) {
                     case 'card':
                         $owner = null;
                         if ($task->getOwnerPHID()) {
                             $owner = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($task->getOwnerPHID()))->executeOne();
                         }
                         $tasks = id(new ProjectBoardTaskCard())->setViewer($user)->setTask($task)->setOwner($owner)->setCanEdit(true)->getItem();
                         $column = id(new PhabricatorProjectColumnQuery())->setViewer($user)->withPHIDs(array($request->getStr('columnPHID')))->executeOne();
                         if (!$column) {
                             return new Aphront404Response();
                         }
                         $positions = id(new PhabricatorProjectColumnPositionQuery())->setViewer($user)->withColumns(array($column))->execute();
                         $task_phids = mpull($positions, 'getObjectPHID');
                         $column_tasks = id(new ManiphestTaskQuery())->setViewer($user)->withPHIDs($task_phids)->execute();
                         if ($order == PhabricatorProjectColumn::ORDER_NATURAL) {
                             // TODO: This is a little bit awkward, because PHP and JS use
                             // slightly different sort order parameters to achieve the same
                             // effect. It would be unify this a bit at some point.
开发者ID:denghp,项目名称:phabricator,代码行数:67,代码来源:ManiphestTaskEditController.php


示例16: dispatchEvent

 protected function dispatchEvent($type, array $data)
 {
     $data += array('workflow' => $this);
     $event = new PhutilEvent($type, $data);
     PhutilEventEngine::dispatchEvent($event);
     return $event;
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:7,代码来源:ArcanistBaseWorkflow.php


示例17: receiveEmail

 public function receiveEmail(PhabricatorMetaMTAReceivedMail $mail)
 {
     // NOTE: We'll drop in here on both the "reply to a task" and "create a
     // new task" workflows! Make sure you test both if you make changes!
     $task = $this->getMailReceiver();
     $is_new_task = !$task->getID();
     $user = $this->getActor();
     $body = $mail->getCleanTextBody();
     $body = trim($body);
     $xactions = array();
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
     $template = new ManiphestTransaction();
     $template->setContentSource($content_source);
     $template->setAuthorPHID($user->getPHID());
     if ($is_new_task) {
         // If this is a new task, create a "User created this task." transaction
         // and then set the title and description.
         $xaction = clone $template;
         $xaction->setTransactionType(ManiphestTransactionType::TYPE_STATUS);
         $xaction->setNewValue(ManiphestTaskStatus::STATUS_OPEN);
         $xactions[] = $xaction;
         $task->setAuthorPHID($user->getPHID());
         $task->setTitle(nonempty($mail->getSubject(), 'Untitled Task'));
         $task->setDescription($body);
     } else {
         $lines = explode("\n", trim($body));
         $first_line = head($lines);
         $command = null;
         $matches = null;
         if (preg_match('/^!(\\w+)/', $first_line, $matches)) {
             $lines = array_slice($lines, 1);
             $body = implode("\n", $lines);
             $body = trim($body);
             $command = $matches[1];
         }
         $ttype = ManiphestTransactionType::TYPE_NONE;
         $new_value = null;
         switch ($command) {
             case 'close':
                 $ttype = ManiphestTransactionType::TYPE_STATUS;
                 $new_value = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED;
                 break;
             case 'claim':
                 $ttype = ManiphestTransactionType::TYPE_OWNER;
                 $new_value = $user->getPHID();
                 break;
             case 'unsubscribe':
                 $ttype = ManiphestTransactionType::TYPE_CCS;
                 $ccs = $task->getCCPHIDs();
                 foreach ($ccs as $k => $phid) {
                     if ($phid == $user->getPHID()) {
                         unset($ccs[$k]);
                     }
                 }
                 $new_value = array_values($ccs);
                 break;
         }
         $xaction = clone $template;
         $xaction->setTransactionType($ttype);
         $xaction->setNewValue($new_value);
         $xaction->setComments($body);
         $xactions[] = $xaction;
     }
     // TODO: We should look at CCs on the mail and add them as CCs.
     $files = $mail->getAttachments();
     if ($files) {
         $file_xaction = clone $template;
         $file_xaction->setTransactionType(ManiphestTransactionType::TYPE_ATTACH);
         $phid_type = PhabricatorPHIDConstants::PHID_TYPE_FILE;
         $new = $task->getAttached();
         foreach ($files as $file_phid) {
             $new[$phid_type][$file_phid] = array();
         }
         $file_xaction->setNewValue($new);
         $xactions[] = $file_xaction;
     }
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array('task' => $task, 'mail' => $mail, 'new' => $is_new_task, 'transactions' => $xactions));
     $event->setUser($user);
     PhutilEventEngine::dispatchEvent($event);
     $task = $event->getValue('task');
     $xactions = $event->getValue('transactions');
     $editor = new ManiphestTransactionEditor();
     $editor->setParentMessageID($mail->getMessageID());
     $editor->applyTransactions($task, $xactions);
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:85,代码来源:ManiphestReplyHandler.php


示例18: dispatchDidUpdateIndexEvent

 private function dispatchDidUpdateIndexEvent($phid, PhabricatorSearchAbstractDocument $document)
 {
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX, array('phid' => $phid, 'object' => $this->loadDocumentByPHID($phid), 'document' => $document));
     $event->setUser($this->getViewer());
     PhutilEventEngine::dispatchEvent($event);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:6,代码来源:PhabricatorSearchDocumentIndexer.php


示例19: sendEvent

 private function sendEvent($edit_id, $event_type)
 {
     if ($this->suppressEvents) {
         return;
     }
     $event = new PhabricatorEvent($event_type, array('id' => $edit_id, 'add' => $this->addEdges, 'rem' => $this->remEdges));
     $event->setUser($this->user);
     PhutilEventEngine::dispatchEvent($event);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:9,代码来源:PhabricatorEdgeEditor.php


示例20: processRequest


//.........这里部分代码省略.........
             }
             if ($files) {
                 $file_map = mpull($files, 'getPHID');
                 $file_map = array_fill_keys($file_map, array());
                 $changes[ManiphestTransactionType::TYPE_ATTACH] = array(PhabricatorPHIDConstants::PHID_TYPE_FILE => $file_map);
             }
             $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
             $template = new ManiphestTransaction();
             $template->setAuthorPHID($user->getPHID());
             $template->setContentSource($content_source);
             $transactions = array();
             foreach ($changes as $type => $value) {
                 $transaction = clone $template;
                 $transaction->setTransactionType($type);
                 $transaction->setNewValue($value);
                 $transactions[] = $transaction;
             }
             if ($aux_fields) {
                 $task->loadAndAttachAuxiliaryAttributes();
                 foreach ($aux_fields as $aux_field) {
                     $transaction = clone $template;
                     $transaction->setTransactionType(ManiphestTransactionType::TYPE_AUXILIARY);
                     $aux_key = $aux_field->getAuxiliaryKey();
                     $transaction->setMetadataValue('aux:key', $aux_key);
                     $transaction->setNewValue($aux_field->getValueForStorage());
                     $transactions[] = $transaction;
                 }
             }
             if ($transactions) {
                 $is_new = !$task->getID();
                 $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
                 $event->setUser($user);
                 $event->setAphrontRequest($request);
                 PhutilEventEngine::dispatchEvent($event);
                 $task = $event->getValue('task');
                 $transactions = $event->getValue('transactions');
                 $editor = new ManiphestTransactionEditor();
                 $editor->setAuxiliaryFields($aux_fields);
                 $editor->applyTransactions($task, $transactions);
                 $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
                 $event->setUser($user);
                 $event->setAphrontRequest($request);
                 PhutilEventEngine::dispatchEvent($event);
             }
             if ($parent_task) {
                 $type_task = PhabricatorPHIDConstants::PHID_TYPE_TASK;
                 // NOTE: It's safe to simply apply this transaction without doing
                 // cycle detection because we know the new task has no children.
                 $new_value = $parent_task->getAttached();
                 $new_value[$type_task][$task->getPHID()] = array();
                 $parent_xaction = clone $template;
                 $attach_type = ManiphestTransactionType::TYPE_ATTACH;
                 $parent_xaction->setTransactionType($attach_type);
                 $parent_xaction->setNewValue($new_value);
                 $editor = new ManiphestTransactionEditor();
                 $editor->setAuxiliaryFields($aux_fields);
                 $editor->applyTransactions($parent_task, array($parent_xaction));
                 $workflow = $parent_task->getID();
             }
             $redirect_uri = '/T' . $task->getID();
             if ($workflow) {
                 $redirect_uri .= '?workflow=' . $workflow;
             }
             return id(new AphrontRedirectResponse())->setURI($redirect_uri);
         }
     } else {
开发者ID:ramons03,项目名称:phabricator,代码行数:67,代码来源:ManiphestTaskEditController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP PhutilServiceProfiler类代码示例发布时间:2022-05-23
下一篇:
PHP PhutilConsole类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap