2015-06-07 07:31:28 -07:00
|
|
|
<?php
|
|
|
|
|
2015-07-06 22:52:04 +10:00
|
|
|
final class PhabricatorProjectSearchField
|
2015-06-07 07:31:28 -07:00
|
|
|
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())
|
2016-02-08 10:27:00 -08:00
|
|
|
->setViewer($this->getViewer())
|
2015-06-07 07:31:28 -07:00
|
|
|
->withSlugs($slugs)
|
|
|
|
->execute();
|
|
|
|
foreach ($projects as $project) {
|
|
|
|
$phids[] = $project->getPHID();
|
|
|
|
}
|
|
|
|
$phids = array_unique($phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-13 06:52:37 -08:00
|
|
|
protected function newConduitParameterType() {
|
|
|
|
return new ConduitProjectListParameterType();
|
|
|
|
}
|
|
|
|
|
2015-06-07 07:31:28 -07:00
|
|
|
}
|