@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move Slowvote rendering into SearchEngine

Summary:
Ref T4986. This adds a bit of structure for handles, since we used to have Controller utilities but no longer do.

Hopefully these will start going faster soon...

Test Plan:

- Checked feed for collateral damage.
- Checked slowvote for collateral damage.
- Made a slowvote panel.

{F151550}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

Differential Revision: https://secure.phabricator.com/D9010

+79 -54
+1 -5
src/__phutil_library_map__.php
··· 5066 5066 'PhabricatorSlowvoteDAO' => 'PhabricatorLiskDAO', 5067 5067 'PhabricatorSlowvoteEditController' => 'PhabricatorSlowvoteController', 5068 5068 'PhabricatorSlowvoteEditor' => 'PhabricatorApplicationTransactionEditor', 5069 - 'PhabricatorSlowvoteListController' => 5070 - array( 5071 - 0 => 'PhabricatorSlowvoteController', 5072 - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 5073 - ), 5069 + 'PhabricatorSlowvoteListController' => 'PhabricatorSlowvoteController', 5074 5070 'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO', 5075 5071 'PhabricatorSlowvotePHIDTypePoll' => 'PhabricatorPHIDType', 5076 5072 'PhabricatorSlowvotePoll' =>
+3 -2
src/applications/feed/query/PhabricatorFeedSearchEngine.php
··· 124 124 return parent::buildSavedQueryFromBuiltin($query_key); 125 125 } 126 126 127 - public function renderResults( 127 + public function renderResultList( 128 128 array $objects, 129 - PhabricatorSavedQuery $query) { 129 + PhabricatorSavedQuery $query, 130 + array $handles) { 130 131 131 132 $builder = new PhabricatorFeedBuilder($objects); 132 133 $builder->setShowHovercards(true);
+25
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 561 561 public function renderResults( 562 562 array $objects, 563 563 PhabricatorSavedQuery $query) { 564 + 565 + $phids = $this->getRequiredHandlePHIDsForResultList($objects, $query); 566 + 567 + if ($phids) { 568 + $handles = id(new PhabricatorHandleQuery()) 569 + ->setViewer($this->requireViewer()) 570 + ->witHPHIDs($phids) 571 + ->execute(); 572 + } else { 573 + $handles = array(); 574 + } 575 + 576 + return $this->renderResultList($objects, $query, $handles); 577 + } 578 + 579 + public function getRequiredHandlePHIDsForResultList( 580 + array $objects, 581 + PhabricatorSavedQuery $query) { 582 + return array(); 583 + } 584 + 585 + public function renderResultList( 586 + array $objects, 587 + PhabricatorSavedQuery $query, 588 + array $handles) { 564 589 throw new Exception(pht('Not supported here yet!')); 565 590 } 566 591
+1 -47
src/applications/slowvote/controller/PhabricatorSlowvoteListController.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group slowvote 5 - */ 6 3 final class PhabricatorSlowvoteListController 7 - extends PhabricatorSlowvoteController 8 - implements PhabricatorApplicationSearchResultsControllerInterface { 4 + extends PhabricatorSlowvoteController { 9 5 10 6 private $queryKey; 11 7 ··· 25 21 ->setNavigation($this->buildSideNavView()); 26 22 27 23 return $this->delegateToController($controller); 28 - } 29 - 30 - public function renderResultsList( 31 - array $polls, 32 - PhabricatorSavedQuery $query) { 33 - assert_instances_of($polls, 'PhabricatorSlowvotePoll'); 34 - $viewer = $this->getRequest()->getUser(); 35 - 36 - $list = id(new PHUIObjectItemListView()) 37 - ->setUser($viewer); 38 - 39 - $phids = mpull($polls, 'getAuthorPHID'); 40 - $handles = $this->loadViewerHandles($phids); 41 - 42 - foreach ($polls as $poll) { 43 - $date_created = phabricator_datetime($poll->getDateCreated(), $viewer); 44 - if ($poll->getAuthorPHID()) { 45 - $author = $handles[$poll->getAuthorPHID()]->renderLink(); 46 - } else { 47 - $author = null; 48 - } 49 - 50 - $item = id(new PHUIObjectItemView()) 51 - ->setObjectName('V'.$poll->getID()) 52 - ->setHeader($poll->getQuestion()) 53 - ->setHref('/V'.$poll->getID()) 54 - ->setDisabled($poll->getIsClosed()) 55 - ->addIcon('none', $date_created); 56 - 57 - $description = $poll->getDescription(); 58 - if (strlen($description)) { 59 - $item->addAttribute(phutil_utf8_shorten($poll->getDescription(), 120)); 60 - } 61 - 62 - if ($author) { 63 - $item->addByline(pht('Author: %s', $author)); 64 - } 65 - 66 - $list->addItem($item); 67 - } 68 - 69 - return $list; 70 24 } 71 25 72 26 }
+49
src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
··· 115 115 return parent::buildSavedQueryFromBuiltin($query_key); 116 116 } 117 117 118 + public function getRequiredHandlePHIDsForResultList( 119 + array $polls, 120 + PhabricatorSavedQuery $query) { 121 + return mpull($polls, 'getAuthorPHID'); 122 + } 123 + 124 + public function renderResultList( 125 + array $polls, 126 + PhabricatorSavedQuery $query, 127 + array $handles) { 128 + 129 + assert_instances_of($polls, 'PhabricatorSlowvotePoll'); 130 + $viewer = $this->requireViewer(); 131 + 132 + $list = id(new PHUIObjectItemListView()) 133 + ->setUser($viewer); 134 + 135 + $phids = mpull($polls, 'getAuthorPHID'); 136 + 137 + foreach ($polls as $poll) { 138 + $date_created = phabricator_datetime($poll->getDateCreated(), $viewer); 139 + if ($poll->getAuthorPHID()) { 140 + $author = $handles[$poll->getAuthorPHID()]->renderLink(); 141 + } else { 142 + $author = null; 143 + } 144 + 145 + $item = id(new PHUIObjectItemView()) 146 + ->setObjectName('V'.$poll->getID()) 147 + ->setHeader($poll->getQuestion()) 148 + ->setHref('/V'.$poll->getID()) 149 + ->setDisabled($poll->getIsClosed()) 150 + ->addIcon('none', $date_created); 151 + 152 + $description = $poll->getDescription(); 153 + if (strlen($description)) { 154 + $item->addAttribute(phutil_utf8_shorten($poll->getDescription(), 120)); 155 + } 156 + 157 + if ($author) { 158 + $item->addByline(pht('Author: %s', $author)); 159 + } 160 + 161 + $list->addItem($item); 162 + } 163 + 164 + return $list; 165 + } 166 + 118 167 }