1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Allow Fund initiatives to be searched for

Summary: Ref T5835. Dump these into global search so you can find them.

Test Plan: {F216290}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5835

Differential Revision: https://secure.phabricator.com/D10682
This commit is contained in:
epriestley 2014-10-13 11:14:02 -07:00
parent 2d0ee77bd4
commit fcdd4a533f
3 changed files with 63 additions and 1 deletions

View file

@ -684,6 +684,7 @@ phutil_register_library_map(array(
'FundInitiativeCloseController' => 'applications/fund/controller/FundInitiativeCloseController.php',
'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php',
'FundInitiativeEditor' => 'applications/fund/editor/FundInitiativeEditor.php',
'FundInitiativeIndexer' => 'applications/fund/search/FundInitiativeIndexer.php',
'FundInitiativeListController' => 'applications/fund/controller/FundInitiativeListController.php',
'FundInitiativePHIDType' => 'applications/fund/phid/FundInitiativePHIDType.php',
'FundInitiativeQuery' => 'applications/fund/query/FundInitiativeQuery.php',
@ -3579,6 +3580,7 @@ phutil_register_library_map(array(
'FundInitiativeCloseController' => 'FundController',
'FundInitiativeEditController' => 'FundController',
'FundInitiativeEditor' => 'PhabricatorApplicationTransactionEditor',
'FundInitiativeIndexer' => 'PhabricatorSearchDocumentIndexer',
'FundInitiativeListController' => 'FundController',
'FundInitiativePHIDType' => 'PhabricatorPHIDType',
'FundInitiativeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',

View file

@ -277,6 +277,8 @@ final class FundInitiativeEditor
return true;
}
protected function supportsSearch() {
return true;
}
}

View file

@ -0,0 +1,58 @@
<?php
final class FundInitiativeIndexer
extends PhabricatorSearchDocumentIndexer {
public function getIndexableObject() {
return new FundInitiative();
}
protected function loadDocumentByPHID($phid) {
$object = id(new FundInitiativeQuery())
->setViewer($this->getViewer())
->withPHIDs(array($phid))
->executeOne();
if (!$object) {
throw new Exception("Unable to load object by phid '{$phid}'!");
}
return $object;
}
protected function buildAbstractDocumentByPHID($phid) {
$initiative = $this->loadDocumentByPHID($phid);
$doc = id(new PhabricatorSearchAbstractDocument())
->setPHID($initiative->getPHID())
->setDocumentType(FundInitiativePHIDType::TYPECONST)
->setDocumentTitle($initiative->getName())
->setDocumentCreated($initiative->getDateCreated())
->setDocumentModified($initiative->getDateModified());
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
$initiative->getOwnerPHID(),
PhabricatorPeopleUserPHIDType::TYPECONST,
$initiative->getDateCreated());
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$initiative->getOwnerPHID(),
PhabricatorPeopleUserPHIDType::TYPECONST,
$initiative->getDateCreated());
$doc->addRelationship(
$initiative->isClosed()
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$initiative->getPHID(),
FundInitiativePHIDType::TYPECONST,
time());
$this->indexTransactions(
$doc,
new FundInitiativeTransactionQuery(),
array($initiative->getPHID()));
return $doc;
}
}