1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-20 02:38:39 +01:00
phorge-phorge/src/applications/phid/conduit/PHIDLookupConduitAPIMethod.php
Joshua Spence 36e2d02d6e phtize all the things
Summary: `pht`ize a whole bunch of strings in rP.

Test Plan: Intense eyeballing.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: hach-que, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12797
2015-05-22 21:16:39 +10:00

47 lines
1.1 KiB
PHP

<?php
final class PHIDLookupConduitAPIMethod extends PHIDConduitAPIMethod {
public function getAPIMethodName() {
return 'phid.lookup';
}
public function getMethodDescription() {
return pht('Look up objects by name.');
}
protected function defineParamTypes() {
return array(
'names' => 'required list<string>',
);
}
protected function defineReturnType() {
return 'nonempty dict<string, wild>';
}
protected function execute(ConduitAPIRequest $request) {
$names = $request->getValue('names');
$query = id(new PhabricatorObjectQuery())
->setViewer($request->getUser())
->withNames($names);
$query->execute();
$name_map = $query->getNamedResults();
$handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser())
->withPHIDs(mpull($name_map, 'getPHID'))
->execute();
$result = array();
foreach ($name_map as $name => $object) {
$phid = $object->getPHID();
$handle = $handles[$phid];
$result[$name] = $this->buildHandleInformationDictionary($handle);
}
return $result;
}
}