Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
<?php | <?php | ||||
/** | /** | ||||
* Represents an abstract search engine for an application. It supports | * Represents an abstract search engine for an application. It supports | ||||
* creating and storing saved queries. | * creating and storing saved queries. | ||||
* | * | ||||
* @task construct Constructing Engines | * @task construct Constructing Engines | ||||
* @task app Applications | * @task app Applications | ||||
* @task builtin Builtin Queries | * @task builtin Builtin Queries | ||||
* @task uri Query URIs | * @task uri Query URIs | ||||
* @task dates Date Filters | * @task dates Date Filters | ||||
* @task order Result Ordering | * @task order Result Ordering | ||||
* @task read Reading Utilities | * @task read Reading Utilities | ||||
* @task exec Paging and Executing Queries | * @task exec Paging and Executing Queries | ||||
* @task render Rendering Results | * @task render Rendering Results | ||||
* @task custom Custom Fields | |||||
*/ | */ | ||||
abstract class PhabricatorApplicationSearchEngine extends Phobject { | abstract class PhabricatorApplicationSearchEngine extends Phobject { | ||||
private $application; | private $application; | ||||
private $viewer; | private $viewer; | ||||
private $errors = array(); | private $errors = array(); | ||||
private $request; | private $request; | ||||
private $context; | private $context; | ||||
▲ Show 20 Lines • Show All 1,042 Lines • ▼ Show 20 Lines | public function renderResults( | ||||
array $objects, | array $objects, | ||||
PhabricatorSavedQuery $query) { | PhabricatorSavedQuery $query) { | ||||
$phids = $this->getRequiredHandlePHIDsForResultList($objects, $query); | $phids = $this->getRequiredHandlePHIDsForResultList($objects, $query); | ||||
if ($phids) { | if ($phids) { | ||||
$handles = id(new PhabricatorHandleQuery()) | $handles = id(new PhabricatorHandleQuery()) | ||||
->setViewer($this->requireViewer()) | ->setViewer($this->requireViewer()) | ||||
->witHPHIDs($phids) | ->withPHIDs($phids) | ||||
->execute(); | ->execute(); | ||||
} else { | } else { | ||||
$handles = array(); | $handles = array(); | ||||
} | } | ||||
return $this->renderResultList($objects, $query, $handles); | return $this->renderResultList($objects, $query, $handles); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Lines | foreach ($extensions as $extension) { | ||||
if ($extension->supportsObject($object)) { | if ($extension->supportsObject($object)) { | ||||
$supported[] = $extension; | $supported[] = $extension; | ||||
} | } | ||||
} | } | ||||
return $supported; | return $supported; | ||||
} | } | ||||
/** | |||||
* Load from object and from storage, and updates Custom Fields instances | |||||
* that are attached to each object. | |||||
* | |||||
* @return map<phid->PhabricatorCustomFieldList> of loaded fields. | |||||
* @task custom | |||||
*/ | |||||
protected function loadCustomFields(array $objects, $role) { | |||||
assert_instances_of($objects, 'PhabricatorCustomFieldInterface'); | |||||
$query = new PhabricatorCustomFieldStorageQuery(); | |||||
$lists = array(); | |||||
foreach ($objects as $object) { | |||||
$field_list = PhabricatorCustomField::getObjectFields($object, $role); | |||||
$field_list->readFieldsFromObject($object); | |||||
foreach ($field_list->getFields() as $field) { | |||||
// TODO move $viewer into PhabricatorCustomFieldStorageQuery | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
$field->setViewer($this->viewer); | |||||
} | |||||
$lists[$object->getPHID()] = $field_list; | |||||
$query->addFields($field_list->getFields()); | |||||
} | |||||
// This updates the field_list objects. | |||||
$query->execute(); | |||||
return $lists; | |||||
} | |||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
This comment has a TODO.