@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class MacroCreateMemeConduitAPIMethod extends MacroConduitAPIMethod {
4
5 public function getAPIMethodName() {
6 return 'macro.creatememe';
7 }
8
9 public function getMethodDescription() {
10 return pht('Generate a meme.');
11 }
12
13 protected function defineParamTypes() {
14 return array(
15 'macroName' => 'string',
16 'upperText' => 'optional string',
17 'lowerText' => 'optional string',
18 );
19 }
20
21 protected function defineReturnType() {
22 return 'string';
23 }
24
25 protected function defineErrorTypes() {
26 return array(
27 'ERR-NOT-FOUND' => pht('Macro was not found.'),
28 );
29 }
30
31 protected function execute(ConduitAPIRequest $request) {
32 $user = $request->getUser();
33
34 $file = id(new PhabricatorMemeEngine())
35 ->setViewer($user)
36 ->setTemplate($request->getValue('macroName'))
37 ->setAboveText($request->getValue('upperText'))
38 ->setBelowText($request->getValue('lowerText'))
39 ->newAsset();
40
41 return array(
42 'uri' => $file->getViewURI(),
43 );
44 }
45
46}