1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Update Differential for handleRequest

Summary: Moves from processRequest to handleRequest.

Test Plan: New diff, edit diff, leave comment, view list, browse revisions, etc.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14252
This commit is contained in:
Chad Little 2015-10-11 08:18:42 -07:00
parent 2f6d3119f5
commit bb37ad65a2
8 changed files with 47 additions and 91 deletions

View file

@ -3,19 +3,13 @@
final class DifferentialCommentPreviewController
extends DifferentialController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->executeOne();
if (!$revision) {
return new Aphront404Response();
@ -119,7 +113,7 @@ final class DifferentialCommentPreviewController
$metadata['action'] = $action;
}
$draft_key = 'differential-comment-'.$this->id;
$draft_key = 'differential-comment-'.$id;
$draft = id(new PhabricatorDraft())
->setAuthorPHID($viewer->getPHID())
->setDraftKey($draft_key)

View file

@ -3,15 +3,9 @@
final class DifferentialCommentSaveController
extends DifferentialController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
@ -19,7 +13,7 @@ final class DifferentialCommentSaveController
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needReviewerStatus(true)
->needReviewerAuthority(true)
->executeOne();

View file

@ -2,23 +2,17 @@
final class DifferentialDiffViewController extends DifferentialController {
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$diff = id(new DifferentialDiffQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->executeOne();
if (!$diff) {
return new Aphront404Response();

View file

@ -3,20 +3,11 @@
final class DifferentialRevisionCloseDetailsController
extends DifferentialController {
private $phid;
public function willProcessRequest(array $data) {
$this->phid = idx($data, 'phid');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$xaction_phid = $this->phid;
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$xaction = id(new PhabricatorObjectQuery())
->withPHIDs(array($xaction_phid))
->withPHIDs(array($request->getURIData('phid')))
->setViewer($viewer)
->executeOne();
if (!$xaction) {

View file

@ -3,24 +3,18 @@
final class DifferentialRevisionEditController
extends DifferentialController {
private $id;
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if (!$this->id) {
$this->id = $request->getInt('revisionID');
if (!$id) {
$id = $request->getInt('revisionID');
}
if ($this->id) {
if ($id) {
$revision = id(new DifferentialRevisionQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->withIDs(array($id))
->needRelationships(true)
->needReviewerStatus(true)
->needActiveDiffs(true)

View file

@ -11,9 +11,8 @@ final class DifferentialRevisionLandController extends DifferentialController {
$this->strategyClass = $data['strategy'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$revision_id = $this->revisionID;

View file

@ -2,19 +2,13 @@
final class DifferentialRevisionListController extends DifferentialController {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
public function handleRequest(AphrontRequest $request) {
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey)
->setQueryKey($request->getURIData('queryKey'))
->setSearchEngine(new DifferentialRevisionSearchEngine())
->setNavigation($this->buildSideNavView());

View file

@ -8,15 +8,11 @@ final class DifferentialRevisionViewController extends DifferentialController {
return true;
}
public function willProcessRequest(array $data) {
$this->revisionID = $data['id'];
}
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$this->revisionID = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn();
$viewer_is_anonymous = !$viewer->isLoggedIn();
$revision = id(new DifferentialRevisionQuery())
->withIDs(array($this->revisionID))
@ -68,7 +64,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$repository = $revision->getRepository();
} else {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($user)
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
}
@ -117,7 +113,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision->loadCommitPHIDs(),
array(
$revision->getAuthorPHID(),
$user->getPHID(),
$viewer->getPHID(),
));
foreach ($revision->getAttached() as $type => $phids) {
@ -130,7 +126,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision,
PhabricatorCustomField::ROLE_VIEW);
$field_list->setViewer($user);
$field_list->setViewer($viewer);
$field_list->readFieldsFromStorage($revision);
$warning_handle_map = array();
@ -174,7 +170,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$new = array_select_keys($changesets, $new_ids);
$query = id(new DifferentialInlineCommentQuery())
->setViewer($user)
->setViewer($viewer)
->needHidden(true)
->withRevisionPHIDs(array($revision->getPHID()));
$inlines = $query->execute();
@ -205,7 +201,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$commit_hashes = array_unique(array_filter($commit_hashes));
if ($commit_hashes) {
$commits_for_links = id(new DiffusionCommitQuery())
->setViewer($user)
->setViewer($viewer)
->withIdentifiers($commit_hashes)
->execute();
$commits_for_links = mpull(
@ -217,7 +213,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
}
$revision_detail = id(new DifferentialRevisionDetailView())
->setUser($user)
->setUser($viewer)
->setRevision($revision)
->setDiff(end($diffs))
->setCustomFields($field_list)
@ -239,7 +235,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
}
$revision_detail->setActions($actions);
$revision_detail->setUser($user);
$revision_detail->setUser($viewer);
$revision_detail_box = $revision_detail->render();
@ -261,7 +257,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$detail_diffs = mpull($detail_diffs, null, 'getPHID');
$buildables = id(new HarbormasterBuildableQuery())
->setViewer($user)
->setViewer($viewer)
->withBuildablePHIDs(array_keys($detail_diffs))
->withManualBuildables(false)
->needBuilds(true)
@ -311,7 +307,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
'/differential/changeset/?view=old',
'/differential/changeset/?view=new');
$changeset_view->setUser($user);
$changeset_view->setUser($viewer);
$changeset_view->setDiff($target);
$changeset_view->setRenderingReferences($rendering_references);
$changeset_view->setVsMap($vs_map);
@ -323,7 +319,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$changeset_view->setTitle(pht('Diff %s', $target->getID()));
$diff_history = id(new DifferentialRevisionUpdateHistoryView())
->setUser($user)
->setUser($viewer)
->setDiffs($diffs)
->setSelectedVersusDiffID($diff_vs)
->setSelectedDiffID($target->getID())
@ -331,7 +327,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
->setCommitsForLinks($commits_for_links);
$local_view = id(new DifferentialLocalCommitsView())
->setUser($user)
->setUser($viewer)
->setLocalCommits(idx($props, 'local:commits'))
->setCommitsForLinks($commits_for_links);
@ -352,13 +348,13 @@ final class DifferentialRevisionViewController extends DifferentialController {
$toc_view = $this->buildTableOfContents(
$changesets,
$visible_changesets,
$target->loadCoverageMap($user));
$target->loadCoverageMap($viewer));
$comment_form = null;
if (!$viewer_is_anonymous) {
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$viewer->getPHID(),
'differential-comment-'.$revision->getID());
$reviewers = array();
@ -394,7 +390,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
'comment/save/'.$revision->getID().'/');
$comment_form->setActionURI($action_uri);
$comment_form->setUser($user);
$comment_form->setUser($viewer);
$comment_form->setDraft($draft);
$comment_form->setReviewers(mpull($reviewers, 'getFullName', 'getPHID'));
$comment_form->setCCs(mpull($ccs, 'getFullName', 'getPHID'));
@ -461,7 +457,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
// TODO: For now, just use this to get "Login to Comment".
$page_pane->appendChild(
id(new PhabricatorApplicationTransactionCommentView())
->setUser($user)
->setUser($viewer)
->setRequestURI($request->getRequestURI()));
}
@ -476,7 +472,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($object_id, '/'.$object_id);
$prefs = $user->loadPreferences();
$prefs = $viewer->loadPreferences();
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
if ($prefs->getPreference($pref_filetree)) {