mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 00:02:41 +01:00
2492fef029
Summary: Ref T8441. Ref T7715. - Update PholioSearchEngine. - Automatically add project fields. - Update Paste to support project search. - Simplify common Query class construction. Test Plan: - Searched for pastes. - Searched for mocks. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7715, T8441 Differential Revision: https://secure.phabricator.com/D13174
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSearchProjectsField
|
|
extends PhabricatorSearchTokenizerField {
|
|
|
|
protected function getDefaultValue() {
|
|
return array();
|
|
}
|
|
|
|
protected function newDatasource() {
|
|
return new PhabricatorProjectLogicalDatasource();
|
|
}
|
|
|
|
protected function getValueFromRequest(AphrontRequest $request, $key) {
|
|
$list = $this->getListFromRequest($request, $key);
|
|
|
|
$phids = array();
|
|
$slugs = array();
|
|
$project_type = PhabricatorProjectProjectPHIDType::TYPECONST;
|
|
foreach ($list as $item) {
|
|
$type = phid_get_type($item);
|
|
if ($type == $project_type) {
|
|
$phids[] = $item;
|
|
} else {
|
|
if (PhabricatorTypeaheadDatasource::isFunctionToken($item)) {
|
|
// If this is a function, pass it through unchanged; we'll evaluate
|
|
// it later.
|
|
$phids[] = $item;
|
|
} else {
|
|
$slugs[] = $item;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($slugs) {
|
|
$projects = id(new PhabricatorProjectQuery())
|
|
->setViewer($this->requireViewer())
|
|
->withSlugs($slugs)
|
|
->execute();
|
|
foreach ($projects as $project) {
|
|
$phids[] = $project->getPHID();
|
|
}
|
|
$phids = array_unique($phids);
|
|
}
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
}
|