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


PHP PhutilEventEngine类代码示例

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


在下文中一共展示了PhutilEventEngine类的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: 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


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