mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-25 21:19:21 +01:00
Summary: Ref T9964. I added several hacks to get these working. Clean them up and pull this into a proper extension. The behavior in the web UI is: - they work in all applications; but - they only show up in the UI if a value is specified. So if you visit `/view/?ids=1,2` you get the field, but normally it's not present. We could refine this later. I'm going to add documentation about how to prefill these forms regardless, which should make this discoverable by reading the documentation. There's one teensey weensey hack: in the API, I push these fields to the top of the table. That one feels OK, since it's purely a convenience/display adjustment. Test Plan: Queried by IDs, reviewed docs. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14769
55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class PhabricatorIDsSearchEngineExtension
|
|
extends PhabricatorSearchEngineExtension {
|
|
|
|
const EXTENSIONKEY = 'ids';
|
|
|
|
public function isExtensionEnabled() {
|
|
return true;
|
|
}
|
|
|
|
public function getExtensionName() {
|
|
return pht('Supports ID/PHID Queries');
|
|
}
|
|
|
|
public function getExtensionOrder() {
|
|
return 1000;
|
|
}
|
|
|
|
public function supportsObject($object) {
|
|
return true;
|
|
}
|
|
|
|
public function getSearchFields($object) {
|
|
return array(
|
|
id(new PhabricatorIDsSearchField())
|
|
->setKey('ids')
|
|
->setLabel(pht('IDs'))
|
|
->setDescription(
|
|
pht('Search for objects with specific IDs.')),
|
|
id(new PhabricatorPHIDsSearchField())
|
|
->setKey('phids')
|
|
->setLabel(pht('PHIDs'))
|
|
->setDescription(
|
|
pht('Search for objects with specific PHIDs.')),
|
|
);
|
|
}
|
|
|
|
public function applyConstraintsToQuery(
|
|
$object,
|
|
$query,
|
|
PhabricatorSavedQuery $saved,
|
|
array $map) {
|
|
|
|
if ($map['ids']) {
|
|
$query->withIDs($map['ids']);
|
|
}
|
|
|
|
if ($map['phids']) {
|
|
$query->withPHIDs($map['phids']);
|
|
}
|
|
|
|
}
|
|
|
|
}
|