Summary:
Ref T9964. Building tables in Remarkup is kind of neat-ish but ends up feeling kind of hacky, and requires weird workarounds if any of the values have `|` in them.
Switch to normal elements instead.
Also move the magic "ids" and "phids" to be more like real fields. I'll clean this up fully in a diff or two, it's just a little tricky because Maniphest has an "ids" field.
Test Plan: {F1024294}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9964
Differential Revision: https://secure.phabricator.com/D14768
73 lines
1.7 KiB
PHP
73 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSpacesSearchEngineExtension
|
|
extends PhabricatorSearchEngineExtension {
|
|
|
|
const EXTENSIONKEY = 'spaces';
|
|
|
|
public function isExtensionEnabled() {
|
|
return PhabricatorApplication::isClassInstalled(
|
|
'PhabricatorSpacesApplication');
|
|
}
|
|
|
|
public function getExtensionName() {
|
|
return pht('Support for Spaces');
|
|
}
|
|
|
|
public function getExtensionOrder() {
|
|
return 4000;
|
|
}
|
|
|
|
public function supportsObject($object) {
|
|
return ($object instanceof PhabricatorSpacesInterface);
|
|
}
|
|
|
|
public function getSearchFields($object) {
|
|
$fields = array();
|
|
|
|
if (PhabricatorSpacesNamespaceQuery::getSpacesExist()) {
|
|
$fields[] = id(new PhabricatorSpacesSearchField())
|
|
->setKey('spacePHIDs')
|
|
->setConduitKey('spaces')
|
|
->setAliases(array('space', 'spaces'))
|
|
->setLabel(pht('Spaces'))
|
|
->setDescription(
|
|
pht('Search for objects in certain spaces.'));
|
|
}
|
|
|
|
return $fields;
|
|
}
|
|
|
|
public function applyConstraintsToQuery(
|
|
$object,
|
|
$query,
|
|
PhabricatorSavedQuery $saved,
|
|
array $map) {
|
|
|
|
if (!empty($map['spacePHIDs'])) {
|
|
$query->withSpacePHIDs($map['spacePHIDs']);
|
|
} else {
|
|
// If the user doesn't search for objects in specific spaces, we
|
|
// default to "all active spaces you have permission to view".
|
|
$query->withSpaceIsArchived(false);
|
|
}
|
|
}
|
|
|
|
public function getFieldSpecificationsForConduit($object) {
|
|
return array(
|
|
'spacePHID' => array(
|
|
'type' => 'phid?',
|
|
'description' => pht(
|
|
'PHID of the policy space this object is part of.'),
|
|
),
|
|
);
|
|
}
|
|
|
|
public function getFieldValuesForConduit($object) {
|
|
return array(
|
|
'spacePHID' => $object->getSpacePHID(),
|
|
);
|
|
}
|
|
|
|
}
|