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


PHP PhutilEventEngine::dispatchEvent方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例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();
     $vary_subject = $this->buildVarySubject();
     $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)->setVarySubject($vary_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);
     }
     $revision = $this->revision;
     if ($revision) {
         if ($revision->getAuthorPHID()) {
             $template->addHeader('X-Differential-Author', '<' . $revision->getAuthorPHID() . '>');
         }
         if ($revision->getReviewers()) {
             $template->addHeader('X-Differential-Reviewers', '<' . implode('>, <', $revision->getReviewers()) . '>');
         }
         if ($revision->getCCPHIDs()) {
             $template->addHeader('X-Differential-CCs', '<' . implode('>, <', $revision->getCCPHIDs()) . '>');
             // Determine explicit CCs (those added by humans) and put them in a
             // header so users can differentiate between Herald CCs and human CCs.
             $relation_subscribed = DifferentialRevision::RELATION_SUBSCRIBED;
             $raw = $revision->getRawRelations($relation_subscribed);
             $reason_phids = ipull($raw, 'reasonPHID');
             $reason_handles = id(new PhabricatorObjectHandleData($reason_phids))->loadHandles();
             $explicit_cc = array();
             foreach ($raw as $relation) {
                 if (!$relation['reasonPHID']) {
                     continue;
                 }
                 $type = $reason_handles[$relation['reasonPHID']]->getType();
                 if ($type == PhabricatorPHIDConstants::PHID_TYPE_USER) {
                     $explicit_cc[] = $relation['objectPHID'];
                 }
             }
             if ($explicit_cc) {
                 $template->addHeader('X-Differential-Explicit-CCs', '<' . implode('>, <', $explicit_cc) . '>');
             }
         }
     }
     $template->setIsBulk(true);
     $template->setRelatedPHID($this->getRevision()->getPHID());
     $mailtags = $this->getMailTags();
     if ($mailtags) {
         $template->setMailTags($mailtags);
     }
     $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:ramons03,项目名称:phabricator,代码行数:77,代码来源:DifferentialMail.php

示例12: applyRequest

 protected function applyRequest(ManiphestTask $task, ConduitAPIRequest $request, $is_new)
 {
     $changes = array();
     if ($is_new) {
         $task->setTitle((string) $request->getValue('title'));
         $task->setDescription((string) $request->getValue('description'));
         $changes[ManiphestTransactionType::TYPE_STATUS] = ManiphestTaskStatus::STATUS_OPEN;
     } else {
         $comments = $request->getValue('comments');
         if (!$is_new && $comments !== null) {
             $changes[ManiphestTransactionType::TYPE_NONE] = null;
         }
         $title = $request->getValue('title');
         if ($title !== null) {
             $changes[ManiphestTransactionType::TYPE_TITLE] = $title;
         }
         $desc = $request->getValue('description');
         if ($desc !== null) {
             $changes[ManiphestTransactionType::TYPE_DESCRIPTION] = $desc;
         }
         $status = $request->getValue('status');
         if ($status !== null) {
             $valid_statuses = ManiphestTaskStatus::getTaskStatusMap();
             if (!isset($valid_statuses[$status])) {
                 throw id(new ConduitException('ERR-INVALID-PARAMETER'))->setErrorDescription('Status set to invalid value.');
             }
             $changes[ManiphestTransactionType::TYPE_STATUS] = $status;
         }
     }
     $priority = $request->getValue('priority');
     if ($priority !== null) {
         $valid_priorities = ManiphestTaskPriority::getTaskPriorityMap();
         if (!isset($valid_priorities[$priority])) {
             throw id(new ConduitException('ERR-INVALID-PARAMETER'))->setErrorDescription('Priority set to invalid value.');
         }
         $changes[ManiphestTransactionType::TYPE_PRIORITY] = $priority;
     }
     $owner_phid = $request->getValue('ownerPHID');
     if ($owner_phid !== null) {
         $this->validatePHIDList(array($owner_phid), PhabricatorPHIDConstants::PHID_TYPE_USER, 'ownerPHID');
         $changes[ManiphestTransactionType::TYPE_OWNER] = $owner_phid;
     }
     $ccs = $request->getValue('ccPHIDs');
     if ($ccs !== null) {
         $this->validatePHIDList($ccs, PhabricatorPHIDConstants::PHID_TYPE_USER, 'ccPHIDS');
         $changes[ManiphestTransactionType::TYPE_CCS] = $ccs;
     }
     $project_phids = $request->getValue('projectPHIDs');
     if ($project_phids !== null) {
         $this->validatePHIDList($project_phids, PhabricatorPHIDConstants::PHID_TYPE_PROJ, 'projectPHIDS');
         $changes[ManiphestTransactionType::TYPE_PROJECTS] = $project_phids;
     }
     $file_phids = $request->getValue('filePHIDs');
     if ($file_phids !== null) {
         $this->validatePHIDList($file_phids, PhabricatorPHIDConstants::PHID_TYPE_FILE, 'filePHIDS');
         $file_map = array_fill_keys($file_phids, true);
         $attached = $task->getAttached();
         $attached[PhabricatorPHIDConstants::PHID_TYPE_FILE] = $file_map;
         $changes[ManiphestTransactionType::TYPE_ATTACH] = $attached;
     }
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
     $template = new ManiphestTransaction();
     $template->setContentSource($content_source);
     $template->setAuthorPHID($request->getUser()->getPHID());
     $transactions = array();
     foreach ($changes as $type => $value) {
         $transaction = clone $template;
         $transaction->setTransactionType($type);
         $transaction->setNewValue($value);
         if ($type == ManiphestTransactionType::TYPE_NONE) {
             $transaction->setComments($comments);
         }
         $transactions[] = $transaction;
     }
     $auxiliary = $request->getValue('auxiliary');
     if ($auxiliary) {
         $task->loadAndAttachAuxiliaryAttributes();
         foreach ($auxiliary as $aux_key => $aux_value) {
             $transaction = clone $template;
             $transaction->setTransactionType(ManiphestTransactionType::TYPE_AUXILIARY);
             $transaction->setMetadataValue('aux:key', $aux_key);
             $transaction->setNewValue($aux_value);
             $transactions[] = $transaction;
         }
     }
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
     $event->setUser($request->getUser());
     $event->setConduitRequest($request);
     PhutilEventEngine::dispatchEvent($event);
     $task = $event->getValue('task');
     $transactions = $event->getValue('transactions');
     $editor = new ManiphestTransactionEditor();
     $editor->applyTransactions($task, $transactions);
     $event = new PhabricatorEvent(PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, array('task' => $task, 'new' => $is_new, 'transactions' => $transactions));
     $event->setUser($request->getUser());
     $event->setConduitRequest($request);
     PhutilEventEngine::dispatchEvent($event);
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:98,代码来源:ConduitAPI_maniphest_Method.php

示例13: dispatchDiffWasCreatedEvent

 private function dispatchDiffWasCreatedEvent($diff_id)
 {
     $event = new PhutilEvent(ArcanistEventType::TYPE_DIFF_WASCREATED, array('diffID' => $diff_id));
     PhutilEventEngine::dispatchEvent($event);
 }
开发者ID:rafikk,项目名称:arcanist,代码行数:5,代码来源:ArcanistDiffWorkflow.php

示例14: 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

示例15: 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


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