Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / macro / conduit / MacroQueryConduitAPIMethod.php
blob44f54a3c8f3fe039b1eb6e4f9e662534c6b23ef4
1 <?php
3 final class MacroQueryConduitAPIMethod extends MacroConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'macro.query';
9 public function getMethodDescription() {
10 return pht('Retrieve image macro information.');
13 protected function defineParamTypes() {
14 return array(
15 'authorPHIDs' => 'optional list<phid>',
16 'phids' => 'optional list<phid>',
17 'ids' => 'optional list<id>',
18 'names' => 'optional list<string>',
19 'nameLike' => 'optional string',
23 protected function defineReturnType() {
24 return 'list<dict>';
27 protected function execute(ConduitAPIRequest $request) {
28 $query = id(new PhabricatorMacroQuery())
29 ->setViewer($request->getUser())
30 ->needFiles(true);
32 $author_phids = $request->getValue('authorPHIDs');
33 $phids = $request->getValue('phids');
34 $ids = $request->getValue('ids');
35 $name_like = $request->getValue('nameLike');
36 $names = $request->getValue('names');
38 if ($author_phids) {
39 $query->withAuthorPHIDs($author_phids);
42 if ($phids) {
43 $query->withPHIDs($phids);
46 if ($ids) {
47 $query->withIDs($ids);
50 if ($name_like) {
51 $query->withNameLike($name_like);
54 if ($names) {
55 $query->withNames($names);
58 $macros = $query->execute();
60 if (!$macros) {
61 return array();
64 $results = array();
65 foreach ($macros as $macro) {
66 $file = $macro->getFile();
67 $results[$macro->getName()] = array(
68 'uri' => $file->getBestURI(),
69 'phid' => $macro->getPHID(),
70 'authorPHID' => $file->getAuthorPHID(),
71 'dateCreated' => $file->getDateCreated(),
72 'filePHID' => $file->getPHID(),
76 return $results;