mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Use setContentSourceFromRequest() in more places
Summary: I introduced this helper at some point, clean up all the code duplication around content sources. Test Plan: Grepped; hit edit interfaces for most/all of these. Reviewers: btrahan, chad, edward Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6030
This commit is contained in:
parent
ee1e04e562
commit
6dda35897a
19 changed files with 31 additions and 107 deletions
|
@ -73,12 +73,7 @@ final class PhabricatorConfigEditController
|
|||
$editor = id(new PhabricatorConfigEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
try {
|
||||
$editor->applyTransactions($config_entry, array($xaction));
|
||||
|
|
|
@ -117,13 +117,7 @@ final class PhabricatorConfigEditor
|
|||
$editor = id(new PhabricatorConfigEditor())
|
||||
->setActor($request->getUser())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($config_entry, array($xaction));
|
||||
}
|
||||
|
|
|
@ -73,13 +73,9 @@ final class ConpherenceNewController extends ConpherenceController {
|
|||
id(new ConpherenceTransactionComment())
|
||||
->setContent($message)
|
||||
->setConpherencePHID($conpherence->getPHID()));
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr()
|
||||
));
|
||||
|
||||
id(new ConpherenceEditor())
|
||||
->setContentSource($content_source)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setActor($user)
|
||||
->applyTransactions($conpherence, $xactions);
|
||||
|
|
|
@ -40,14 +40,9 @@ final class ConpherenceUpdateController
|
|||
$e_file = array();
|
||||
$errors = array();
|
||||
if ($request->isFormPost()) {
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr()
|
||||
));
|
||||
$editor = id(new ConpherenceEditor())
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSource($content_source)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setActor($user);
|
||||
|
||||
switch ($action) {
|
||||
|
|
|
@ -40,12 +40,7 @@ final class PhabricatorMacroCommentController
|
|||
$editor = id(new PhabricatorMacroEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)))
|
||||
->setContentSourceFromRequest($request)
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
try {
|
||||
|
|
|
@ -35,12 +35,7 @@ final class PhabricatorMacroDisableController
|
|||
|
||||
$editor = id(new PhabricatorMacroEditor())
|
||||
->setActor($user)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$xactions = $editor->applyTransactions($macro, array($xaction));
|
||||
|
||||
|
|
|
@ -118,12 +118,7 @@ final class PhabricatorMacroEditController
|
|||
$editor = id(new PhabricatorMacroEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$xactions = $editor->applyTransactions($original, $xactions);
|
||||
|
||||
|
|
|
@ -38,6 +38,14 @@ final class PhabricatorContentSource {
|
|||
return $obj;
|
||||
}
|
||||
|
||||
public static function newFromRequest(AphrontRequest $request) {
|
||||
return self::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
));
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
return json_encode(array(
|
||||
'source' => $this->getSource(),
|
||||
|
|
|
@ -69,12 +69,7 @@ final class PhluxEditController extends PhluxController {
|
|||
$editor = id(new PhluxVariableEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$xactions = array();
|
||||
$xactions[] = id(new PhluxTransaction())
|
||||
|
|
|
@ -42,14 +42,7 @@ final class PholioInlineSaveController extends PholioController {
|
|||
$draft->setAuthorPHID($user->getPHID());
|
||||
$draft->setEditPolicy($user->getPHID());
|
||||
$draft->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
));
|
||||
|
||||
$draft->setContentSource($content_source);
|
||||
$draft->setContentSourceFromRequest($request);
|
||||
|
||||
$draft->setWidth($request->getInt('endX') - $request->getInt('startX'));
|
||||
$draft->setHeight($request->getInt('endY') - $request->getInt('startY'));
|
||||
|
|
|
@ -37,12 +37,6 @@ final class PholioMockCommentController extends PholioController {
|
|||
|
||||
$comment = $request->getStr('comment');
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
));
|
||||
|
||||
$xactions = array();
|
||||
|
||||
$inline_comments = id(new PholioTransactionComment())->loadAllWhere(
|
||||
|
@ -66,7 +60,7 @@ final class PholioMockCommentController extends PholioController {
|
|||
|
||||
$editor = id(new PholioMockEditor())
|
||||
->setActor($user)
|
||||
->setContentSource($content_source)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
|
|
|
@ -110,12 +110,6 @@ final class PholioMockEditController extends PholioController {
|
|||
}
|
||||
|
||||
if (!$errors) {
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
));
|
||||
|
||||
foreach ($xactions as $type => $value) {
|
||||
$xactions[$type] = id(new PholioTransaction())
|
||||
->setTransactionType($type)
|
||||
|
@ -124,7 +118,7 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$mock->openTransaction();
|
||||
$editor = id(new PholioMockEditor())
|
||||
->setContentSource($content_source)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setActor($user);
|
||||
|
||||
|
|
|
@ -39,12 +39,7 @@ abstract class PhortuneController extends PhabricatorController {
|
|||
|
||||
$editor = id(new PhortuneAccountEditor())
|
||||
->setActor($user)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
// We create an account for you the first time you visit Phortune.
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
|
|
|
@ -28,12 +28,7 @@ final class ReleephRequestActionController extends ReleephController {
|
|||
$editor = id(new ReleephRequestTransactionalEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$xactions = array();
|
||||
|
||||
|
|
|
@ -28,12 +28,7 @@ final class ReleephRequestCommentController
|
|||
$editor = id(new ReleephRequestTransactionalEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)))
|
||||
->setContentSourceFromRequest($request)
|
||||
->setIsPreview($is_preview);
|
||||
|
||||
try {
|
||||
|
|
|
@ -140,12 +140,7 @@ final class ReleephRequestEditController extends ReleephController {
|
|||
$editor = id(new ReleephRequestTransactionalEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
$editor->applyTransactions($rq, $xactions);
|
||||
return id(new AphrontRedirectResponse())->setURI($origin_uri);
|
||||
}
|
||||
|
|
|
@ -76,12 +76,7 @@ final class PhabricatorSubscriptionsEditController
|
|||
$editor = id($object->getApplicationTransactionEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)));
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($object, array($xaction));
|
||||
} else {
|
||||
|
|
|
@ -49,12 +49,7 @@ final class PhabricatorApplicationTransactionCommentEditController
|
|||
|
||||
$editor = id(new PhabricatorApplicationTransactionCommentEditor())
|
||||
->setActor($user)
|
||||
->setContentSource(
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_WEB,
|
||||
array(
|
||||
'ip' => $request->getRemoteAddr(),
|
||||
)))
|
||||
->setContentSourceFromRequest($request)
|
||||
->applyEdit($xaction, $comment);
|
||||
|
||||
if ($request->isAjax()) {
|
||||
|
|
|
@ -47,6 +47,11 @@ abstract class PhabricatorApplicationTransactionComment
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setContentSourceFromRequest(AphrontRequest $request) {
|
||||
return $this->setContentSource(
|
||||
PhabricatorContentSource::newFromRequest($request));
|
||||
}
|
||||
|
||||
public function getContentSource() {
|
||||
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue