Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/macro/conduit/MacroCreateMemeConduitAPIMethod.php
13441 views
1
<?php
2
3
final class MacroCreateMemeConduitAPIMethod extends MacroConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'macro.creatememe';
7
}
8
9
public function getMethodStatus() {
10
return self::METHOD_STATUS_UNSTABLE;
11
}
12
13
public function getMethodDescription() {
14
return pht('Generate a meme.');
15
}
16
17
protected function defineParamTypes() {
18
return array(
19
'macroName' => 'string',
20
'upperText' => 'optional string',
21
'lowerText' => 'optional string',
22
);
23
}
24
25
protected function defineReturnType() {
26
return 'string';
27
}
28
29
protected function defineErrorTypes() {
30
return array(
31
'ERR-NOT-FOUND' => pht('Macro was not found.'),
32
);
33
}
34
35
protected function execute(ConduitAPIRequest $request) {
36
$user = $request->getUser();
37
38
$file = id(new PhabricatorMemeEngine())
39
->setViewer($user)
40
->setTemplate($request->getValue('macroName'))
41
->setAboveText($request->getValue('upperText'))
42
->setBelowText($request->getValue('lowerText'))
43
->newAsset();
44
45
return array(
46
'uri' => $file->getViewURI(),
47
);
48
}
49
50
}
51
52