1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/applications/macro/conduit/MacroQueryConduitAPIMethod.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

79 lines
1.8 KiB
PHP

<?php
final class MacroQueryConduitAPIMethod extends MacroConduitAPIMethod {
public function getAPIMethodName() {
return 'macro.query';
}
public function getMethodDescription() {
return pht('Retrieve image macro information.');
}
protected function defineParamTypes() {
return array(
'authorPHIDs' => 'optional list<phid>',
'phids' => 'optional list<phid>',
'ids' => 'optional list<id>',
'names' => 'optional list<string>',
'nameLike' => 'optional string',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$query = id(new PhabricatorMacroQuery())
->setViewer($request->getUser())
->needFiles(true);
$author_phids = $request->getValue('authorPHIDs');
$phids = $request->getValue('phids');
$ids = $request->getValue('ids');
$name_like = $request->getValue('nameLike');
$names = $request->getValue('names');
if ($author_phids) {
$query->withAuthorPHIDs($author_phids);
}
if ($phids) {
$query->withPHIDs($phids);
}
if ($ids) {
$query->withIDs($ids);
}
if ($name_like) {
$query->withNameLike($name_like);
}
if ($names) {
$query->withNames($names);
}
$macros = $query->execute();
if (!$macros) {
return array();
}
$results = array();
foreach ($macros as $macro) {
$file = $macro->getFile();
$results[$macro->getName()] = array(
'uri' => $file->getBestURI(),
'phid' => $macro->getPHID(),
'authorPHID' => $file->getAuthorPHID(),
'dateCreated' => $file->getDateCreated(),
'filePHID' => $file->getPHID(),
);
}
return $results;
}
}