3 final class FundBackerSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
8 public function setInitiative(FundInitiative
$initiative) {
9 $this->initiative
= $initiative;
13 public function getInitiative() {
14 return $this->initiative
;
17 public function getResultTypeDescription() {
18 return pht('Fund Backers');
21 public function getApplicationClassName() {
22 return 'PhabricatorFundApplication';
25 public function buildSavedQueryFromRequest(AphrontRequest
$request) {
26 $saved = new PhabricatorSavedQuery();
30 $this->readUsersFromRequest($request, 'backers'));
35 public function buildQueryFromSavedQuery(PhabricatorSavedQuery
$saved) {
36 $query = id(new FundBackerQuery());
38 $query->withStatuses(array(FundBacker
::STATUS_PURCHASED
));
40 if ($this->getInitiative()) {
41 $query->withInitiativePHIDs(
43 $this->getInitiative()->getPHID(),
47 $backer_phids = $saved->getParameter('backerPHIDs');
49 $query->withBackerPHIDs($backer_phids);
55 public function buildSearchForm(
56 AphrontFormView
$form,
57 PhabricatorSavedQuery
$saved) {
59 $backer_phids = $saved->getParameter('backerPHIDs', array());
63 id(new AphrontFormTokenizerControl())
64 ->setLabel(pht('Backers'))
66 ->setDatasource(new PhabricatorPeopleDatasource())
67 ->setValue($backer_phids));
70 protected function getURI($path) {
71 if ($this->getInitiative()) {
72 return '/fund/backers/'.$this->getInitiative()->getID().'/'.$path;
74 return '/fund/backers/'.$path;
78 protected function getBuiltinQueryNames() {
80 $names['all'] = pht('All Backers');
85 public function buildSavedQueryFromBuiltin($query_key) {
86 $query = $this->newSavedQuery();
87 $query->setQueryKey($query_key);
94 return parent
::buildSavedQueryFromBuiltin($query_key);
97 protected function getRequiredHandlePHIDsForResultList(
99 PhabricatorSavedQuery
$query) {
102 foreach ($backers as $backer) {
103 $phids[] = $backer->getBackerPHID();
104 $phids[] = $backer->getInitiativePHID();
110 protected function renderResultList(
112 PhabricatorSavedQuery
$query,
114 assert_instances_of($backers, 'FundBacker');
116 $viewer = $this->requireViewer();
119 foreach ($backers as $backer) {
121 $handles[$backer->getInitiativePHID()]->renderLink(),
122 $handles[$backer->getBackerPHID()]->renderLink(),
123 $backer->getAmountAsCurrency()->formatForDisplay(),
124 phabricator_datetime($backer->getDateCreated(), $viewer),
128 $table = id(new AphrontTableView($rows))
129 ->setNoDataString(pht('No backers found.'))
145 $result = new PhabricatorApplicationSearchResultView();
146 $result->setTable($table);