1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-02 02:40:58 +01:00

Vastly expanded macro.query's capabilities

Summary:
Depends on D5420; Fixes T2822

Increased `macro.query`'s capabilities by at least 9001%!

Test Plan: Used it in several combination of query strings. Behaves as expected.

Reviewers: epriestley

CC: aran, Korvin

Maniphest Tasks: T2822

Differential Revision: https://secure.phabricator.com/D5421
This commit is contained in:
Anh Nhan Nguyen 2013-03-26 14:29:03 -07:00 committed by epriestley
parent 9a6c912ef6
commit 92003b6822

View file

@ -11,6 +11,11 @@ final class ConduitAPI_macro_query_Method extends ConduitAPI_macro_Method {
public function defineParamTypes() { public function defineParamTypes() {
return array( return array(
'authorPHIDs' => 'optional list<phid>',
'phids' => 'optional list<phid>',
'ids' => 'optional list<id>',
'names' => 'optional list<string>',
'nameLike' => 'optional string',
); );
} }
@ -24,14 +29,49 @@ final class ConduitAPI_macro_query_Method extends ConduitAPI_macro_Method {
} }
protected function execute(ConduitAPIRequest $request) { protected function execute(ConduitAPIRequest $request) {
$macros = id(new PhabricatorMacroQuery()) $query = new PhabricatorMacroQuery();
->setViewer($request->getUser()) $query->setViewer($request->getUser());
->execute();
$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(); $results = array();
foreach ($macros as $macro) { foreach ($macros as $macro) {
$file = $macro->getFile();
$results[$macro->getName()] = array( $results[$macro->getName()] = array(
'uri' => $macro->getFile()->getBestURI(), 'uri' => $file->getBestURI(),
'phid' => $macro->getPHID(),
'authorPHID' => $file->getAuthorPHID(),
'dateCreated' => $file->getDateCreated(),
); );
} }