1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-18 01:38:39 +01:00
phorge-phorge/src/applications/search/field/PhabricatorSearchSpacesField.php

44 lines
981 B
PHP
Raw Normal View History

<?php
final class PhabricatorSearchSpacesField
extends PhabricatorSearchTokenizerField {
protected function getDefaultValue() {
return array();
}
protected function newDatasource() {
return new PhabricatorSpacesNamespaceDatasource();
}
protected function getValueFromRequest(AphrontRequest $request, $key) {
$viewer = $this->getViewer();
$list = $this->getListFromRequest($request, $key);
$type = new PhabricatorSpacesNamespacePHIDType();
$phids = array();
$names = array();
foreach ($list as $item) {
if ($type->canLoadNamedObject($item)) {
$names[] = $item;
} else {
$phids[] = $item;
}
}
if ($names) {
$spaces = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->withNames($names)
->execute();
foreach (mpull($spaces, 'getPHID') as $phid) {
$phids[] = $phid;
}
$phids = array_unique($phids);
}
return $phids;
}
}