Adding macro create method.
This commit is contained in:
@@ -9,12 +9,23 @@ final class PhabricatorMacroMemeController
|
||||
$upper_text = $request->getStr('uppertext');
|
||||
$lower_text = $request->getStr('lowertext');
|
||||
$user = $request->getUser();
|
||||
|
||||
$uri = PhabricatorMacroMemeController::generateMacro($user, $macro_name,
|
||||
$upper_text, $lower_text);
|
||||
if ($uri === false) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
}
|
||||
|
||||
public static function generateMacro($user, $macro_name, $upper_text,
|
||||
$lower_text) {
|
||||
$macro = id(new PhabricatorMacroQuery())
|
||||
->setViewer($user)
|
||||
->withNames(array($macro_name))
|
||||
->executeOne();
|
||||
if (!$macro) {
|
||||
return new Aphront404Response();
|
||||
return false;
|
||||
}
|
||||
$file = $macro->getFile();
|
||||
|
||||
@@ -29,7 +40,7 @@ final class PhabricatorMacroMemeController
|
||||
if ($xform) {
|
||||
$memefile = id(new PhabricatorFile())->loadOneWhere(
|
||||
'phid = %s', $xform->getTransformedPHID());
|
||||
return id(new AphrontRedirectResponse())->setURI($memefile->getBestURI());
|
||||
return $memefile->getBestURI();
|
||||
}
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
$transformers = (new PhabricatorImageTransformer());
|
||||
@@ -40,6 +51,7 @@ final class PhabricatorMacroMemeController
|
||||
$xfile->setTransformedPHID($newfile->getPHID());
|
||||
$xfile->setTransform($hash);
|
||||
$xfile->save();
|
||||
return id(new AphrontRedirectResponse())->setURI($newfile->getBestURI());
|
||||
|
||||
return $newfile->getBestURI();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user