Write pathway for Differential Comments
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class DifferentialCommentSaveController extends DifferentialController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
if (!$request->isFormPost()) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$revision_id = $request->getInt('revision_id');
|
||||
$revision = id(new DifferentialRevision())->load($revision_id);
|
||||
if (!$revision) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$comment = $request->getStr('comment');
|
||||
$action = $request->getStr('action');
|
||||
$reviewers = $request->getStr('reviewers');
|
||||
|
||||
$editor = new DifferentialCommentEditor(
|
||||
$revision,
|
||||
$request->getUser()->getPHID(),
|
||||
$action);
|
||||
|
||||
$editor
|
||||
->setMessage($comment)
|
||||
->setAttachInlineComments(true)
|
||||
->setAddCC($action != DifferentialAction::ACTION_RESIGN)
|
||||
->setAddedReviewers($reviewers)
|
||||
->save();
|
||||
|
||||
// TODO: Diff change detection?
|
||||
// TODO: Clear draft
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/D'.$revision->getID());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/400');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/differential/editor/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DifferentialCommentSaveController.php');
|
||||
@@ -83,6 +83,7 @@ class DifferentialRevisionViewController extends DifferentialController {
|
||||
$comment_form = new DifferentialAddCommentView();
|
||||
$comment_form->setRevision($revision);
|
||||
$comment_form->setActions($this->getRevisionCommentActions($revision));
|
||||
$comment_form->setActionURI('/differential/comment/save/');
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
'<div class="differential-primary-pane">'.
|
||||
|
||||
Reference in New Issue
Block a user