Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13979775
D13724.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D13724.diff
View Options
diff --git a/src/applications/macro/controller/PhabricatorMacroAudioController.php b/src/applications/macro/controller/PhabricatorMacroAudioController.php
--- a/src/applications/macro/controller/PhabricatorMacroAudioController.php
+++ b/src/applications/macro/controller/PhabricatorMacroAudioController.php
@@ -2,26 +2,20 @@
final class PhabricatorMacroAudioController extends PhabricatorMacroController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
$this->requireApplicationCapability(
PhabricatorMacroManageCapability::CAPABILITY);
- $request = $this->getRequest();
- $viewer = $request->getUser();
-
$macro = id(new PhabricatorMacroQuery())
->setViewer($viewer)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
))
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$macro) {
diff --git a/src/applications/macro/controller/PhabricatorMacroCommentController.php b/src/applications/macro/controller/PhabricatorMacroCommentController.php
--- a/src/applications/macro/controller/PhabricatorMacroCommentController.php
+++ b/src/applications/macro/controller/PhabricatorMacroCommentController.php
@@ -3,23 +3,17 @@
final class PhabricatorMacroCommentController
extends PhabricatorMacroController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->executeOne();
if (!$macro) {
return new Aphront404Response();
@@ -38,7 +32,7 @@
->setContent($request->getStr('comment')));
$editor = id(new PhabricatorMacroEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContinueOnNoEffect($request->isContinueRequest())
->setContentSourceFromRequest($request)
->setIsPreview($is_preview);
@@ -57,7 +51,7 @@
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())
- ->setViewer($user)
+ ->setViewer($viewer)
->setTransactions($xactions)
->setIsPreview($is_preview);
} else {
diff --git a/src/applications/macro/controller/PhabricatorMacroDisableController.php b/src/applications/macro/controller/PhabricatorMacroDisableController.php
--- a/src/applications/macro/controller/PhabricatorMacroDisableController.php
+++ b/src/applications/macro/controller/PhabricatorMacroDisableController.php
@@ -3,28 +3,22 @@
final class PhabricatorMacroDisableController
extends PhabricatorMacroController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
$this->requireApplicationCapability(
PhabricatorMacroManageCapability::CAPABILITY);
- $request = $this->getRequest();
- $user = $request->getUser();
-
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->executeOne();
if (!$macro) {
return new Aphront404Response();
}
- $view_uri = $this->getApplicationURI('/view/'.$this->id.'/');
+ $view_uri = $this->getApplicationURI('/view/'.$id.'/');
if ($request->isDialogFormPost() || $macro->getIsDisabled()) {
$xaction = id(new PhabricatorMacroTransaction())
@@ -32,7 +26,7 @@
->setNewValue($macro->getIsDisabled() ? 0 : 1);
$editor = id(new PhabricatorMacroEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContentSourceFromRequest($request);
$xactions = $editor->applyTransactions($macro, array($xaction));
@@ -52,7 +46,7 @@
'Really disable the much-beloved image macro %s? '.
'It will be sorely missed.',
$macro->getName())))
- ->setSubmitURI($this->getApplicationURI('/disable/'.$this->id.'/'))
+ ->setSubmitURI($this->getApplicationURI('/disable/'.$id.'/'))
->addSubmitButton(pht('Disable'))
->addCancelButton($view_uri);
diff --git a/src/applications/macro/controller/PhabricatorMacroEditController.php b/src/applications/macro/controller/PhabricatorMacroEditController.php
--- a/src/applications/macro/controller/PhabricatorMacroEditController.php
+++ b/src/applications/macro/controller/PhabricatorMacroEditController.php
@@ -2,23 +2,17 @@
final class PhabricatorMacroEditController extends PhabricatorMacroController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
$this->requireApplicationCapability(
PhabricatorMacroManageCapability::CAPABILITY);
- $request = $this->getRequest();
- $user = $request->getUser();
-
- if ($this->id) {
+ if ($id) {
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->needFiles(true)
->executeOne();
if (!$macro) {
@@ -26,7 +20,7 @@
}
} else {
$macro = new PhabricatorFileImageMacro();
- $macro->setAuthorPHID($user->getPHID());
+ $macro->setAuthorPHID($viewer->getPHID());
}
$errors = array();
@@ -66,7 +60,7 @@
$_FILES['file'],
array(
'name' => $request->getStr('name'),
- 'authorPHID' => $user->getPHID(),
+ 'authorPHID' => $viewer->getPHID(),
'isExplicitUpload' => true,
'canCDN' => true,
));
@@ -75,7 +69,7 @@
// Rate limit outbound fetches to make this mechanism less useful for
// scanning networks and ports.
PhabricatorSystemActionEngine::willTakeAction(
- array($user->getPHID()),
+ array($viewer->getPHID()),
new PhabricatorFilesOutboundRequestAction(),
1);
@@ -101,7 +95,7 @@
$mime_type));
} else {
$file
- ->setAuthorPHID($user->getPHID())
+ ->setAuthorPHID($viewer->getPHID())
->save();
}
} catch (HTTPFutureHTTPResponseStatus $status) {
@@ -114,7 +108,7 @@
}
} else if ($request->getStr('phid')) {
$file = id(new PhabricatorFileQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withPHIDs(array($request->getStr('phid')))
->executeOne();
}
@@ -152,7 +146,7 @@
}
$editor = id(new PhabricatorMacroEditor())
- ->setActor($user)
+ ->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request);
diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php
--- a/src/applications/macro/controller/PhabricatorMacroListController.php
+++ b/src/applications/macro/controller/PhabricatorMacroListController.php
@@ -2,19 +2,15 @@
final class PhabricatorMacroListController extends PhabricatorMacroController {
- private $key;
-
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->key = idx($data, 'key');
- }
+ public function handleRequest(AphrontRequest $request) {
+ $key = $request->getURIData('key');
- public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController())
- ->setQueryKey($this->key)
+ ->setQueryKey($key)
->setSearchEngine(new PhabricatorMacroSearchEngine())
->setNavigation($this->buildSideNavView());
diff --git a/src/applications/macro/controller/PhabricatorMacroMemeController.php b/src/applications/macro/controller/PhabricatorMacroMemeController.php
--- a/src/applications/macro/controller/PhabricatorMacroMemeController.php
+++ b/src/applications/macro/controller/PhabricatorMacroMemeController.php
@@ -7,14 +7,13 @@
return true;
}
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$macro_name = $request->getStr('macro');
$upper_text = $request->getStr('uppertext');
$lower_text = $request->getStr('lowertext');
- $user = $request->getUser();
+ $viewer = $request->getViewer();
- $uri = self::generateMacro($user, $macro_name,
+ $uri = self::generateMacro($viewer, $macro_name,
$upper_text, $lower_text);
if ($uri === false) {
return new Aphront404Response();
@@ -24,10 +23,10 @@
->setURI($uri);
}
- public static function generateMacro($user, $macro_name, $upper_text,
+ public static function generateMacro($viewer, $macro_name, $upper_text,
$lower_text) {
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withNames(array($macro_name))
->needFiles(true)
->executeOne();
@@ -46,7 +45,7 @@
if ($xform) {
$memefile = id(new PhabricatorFileQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withPHIDs(array($xform->getTransformedPHID()))
->executeOne();
if ($memefile) {
diff --git a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php
--- a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php
+++ b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php
@@ -3,9 +3,8 @@
final class PhabricatorMacroMemeDialogController
extends PhabricatorMacroController {
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
$phid = head($request->getArr('macro'));
$above = $request->getStr('above');
@@ -19,7 +18,7 @@
$errors[] = pht('Macro name is required.');
} else {
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
+ ->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
if (!$macro) {
@@ -45,7 +44,7 @@
}
$view = id(new AphrontFormView())
- ->setUser($user)
+ ->setUser($viewer)
->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Macro'))
@@ -65,7 +64,7 @@
->setValue($below));
$dialog = id(new AphrontDialogView())
- ->setUser($user)
+ ->setUser($viewer)
->setTitle(pht('Create Meme'))
->appendForm($view)
->addCancelButton('/')
diff --git a/src/applications/macro/controller/PhabricatorMacroViewController.php b/src/applications/macro/controller/PhabricatorMacroViewController.php
--- a/src/applications/macro/controller/PhabricatorMacroViewController.php
+++ b/src/applications/macro/controller/PhabricatorMacroViewController.php
@@ -3,23 +3,17 @@
final class PhabricatorMacroViewController
extends PhabricatorMacroController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
public function shouldAllowPublic() {
return true;
}
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$macro = id(new PhabricatorMacroQuery())
- ->setViewer($user)
- ->withIDs(array($this->id))
+ ->setViewer($viewer)
+ ->withIDs(array($id))
->needFiles(true)
->executeOne();
if (!$macro) {
@@ -55,7 +49,7 @@
new PhabricatorMacroTransactionQuery());
$header = id(new PHUIHeaderView())
- ->setUser($user)
+ ->setUser($viewer)
->setPolicyObject($macro)
->setHeader($title_long);
@@ -71,10 +65,10 @@
? pht('Add Comment')
: pht('Grovel in Awe');
- $draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID());
+ $draft = PhabricatorDraft::newFromUserAndKey($viewer, $macro->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
- ->setUser($user)
+ ->setUser($viewer)
->setObjectPHID($macro->getPHID())
->setDraft($draft)
->setHeaderText($comment_header)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 20 2024, 6:29 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6718948
Default Alt Text
D13724.diff (13 KB)
Attached To
Mode
D13724: Convert Macro to handleRequest
Attached
Detach File
Event Timeline
Log In to Comment