Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/conduit/MacroCreateMemeConduitAPIMethod.php
| Show All 29 Lines | protected function defineErrorTypes() { | ||||
| return array( | return array( | ||||
| 'ERR-NOT-FOUND' => pht('Macro was not found.'), | 'ERR-NOT-FOUND' => pht('Macro was not found.'), | ||||
| ); | ); | ||||
| } | } | ||||
| protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $macro_name = $request->getValue('macroName'); | $file = id(new PhabricatorMemeEngine()) | ||||
| $upper_text = $request->getValue('upperText'); | ->setViewer($user) | ||||
| $lower_text = $request->getValue('lowerText'); | ->setTemplate($request->getValue('macroName')) | ||||
| ->setAboveText($request->getValue('upperText')) | |||||
| $uri = PhabricatorMacroMemeController::generateMacro( | ->setBelowText($request->getValue('lowerText')) | ||||
| $user, | ->newAsset(); | ||||
| $macro_name, | |||||
| $upper_text, | |||||
| $lower_text); | |||||
| if (!$uri) { | |||||
| throw new ConduitException('ERR-NOT-FOUND'); | |||||
| } | |||||
| return array( | return array( | ||||
| 'uri' => $uri, | 'uri' => $file->getViewURI(), | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||