Differential D14842 Diff 35875 src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | final class PhabricatorSearchApplicationSearchEngine | ||||
} | } | ||||
public static function getIndexableDocumentTypes( | public static function getIndexableDocumentTypes( | ||||
PhabricatorUser $viewer = null) { | PhabricatorUser $viewer = null) { | ||||
// TODO: This is inelegant and not very efficient, but gets us reasonable | // TODO: This is inelegant and not very efficient, but gets us reasonable | ||||
// results. It would be nice to do this more elegantly. | // results. It would be nice to do this more elegantly. | ||||
$indexers = id(new PhutilClassMapQuery()) | $objects = id(new PhutilClassMapQuery()) | ||||
->setAncestorClass('PhabricatorSearchDocumentIndexer') | ->setAncestorClass('PhabricatorFulltextInterface') | ||||
->execute(); | ->execute(); | ||||
$type_map = array(); | |||||
foreach ($objects as $object) { | |||||
$phid_type = phid_get_type($object->generatePHID()); | |||||
$type_map[$phid_type] = $object; | |||||
} | |||||
if ($viewer) { | if ($viewer) { | ||||
$types = PhabricatorPHIDType::getAllInstalledTypes($viewer); | $types = PhabricatorPHIDType::getAllInstalledTypes($viewer); | ||||
} else { | } else { | ||||
$types = PhabricatorPHIDType::getAllTypes(); | $types = PhabricatorPHIDType::getAllTypes(); | ||||
} | } | ||||
$results = array(); | $results = array(); | ||||
foreach ($types as $type) { | foreach ($types as $type) { | ||||
$typeconst = $type->getTypeConstant(); | $typeconst = $type->getTypeConstant(); | ||||
foreach ($indexers as $indexer) { | $object = idx($type_map, $typeconst); | ||||
$fake_phid = 'PHID-'.$typeconst.'-fake'; | if ($object) { | ||||
if ($indexer->shouldIndexDocumentByPHID($fake_phid)) { | |||||
$results[$typeconst] = $type->getTypeName(); | $results[$typeconst] = $type->getTypeName(); | ||||
} | } | ||||
} | } | ||||
} | |||||
asort($results); | asort($results); | ||||
return $results; | return $results; | ||||
} | } | ||||
public function shouldUseOffsetPaging() { | public function shouldUseOffsetPaging() { | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |