revisionID = $data['id']; } public function processRequest() { $request = $this->getRequest(); $changeset = $request->getInt('changeset'); $is_new = $request->getInt('is_new'); $on_right = $request->getInt('on_right'); $number = $request->getInt('number'); $length = $request->getInt('length'); $text = $request->getStr('text'); $op = $request->getStr('op'); $user = $request->getUser(); $submit_uri = '/differential/comment/inline/edit/'.$this->revisionID.'/'; switch ($op) { case 'delete': if ($request->isFormPost()) { // do the delete; return new AphrontAjaxResponse(); } $dialog = new AphrontDialogView(); $dialog->setTitle('Really delete this comment?'); return id(new AphrontDialogResponse())->setDialog($dialog); case 'edit': $dialog = new AphrontDialogView(); return id(new AphrontDialogResponse())->setDialog($dialog); case 'create': if (!$request->isFormPost() || !strlen($text)) { return new AphrontAjaxResponse(); } $factory = new DifferentialMarkupEngineFactory(); $engine = $factory->newDifferentialCommentMarkupEngine(); $phids = array($user->getPHID()); $handles = id(new PhabricatorObjectHandleData($phids)) ->loadHandles(); $inline = id(new DifferentialInlineComment()) ->setRevisionID($this->revisionID) ->setChangesetID($changeset) ->setCommentID(null) ->setAuthorPHID($user->getPHID()) ->setLineNumber($number) ->setLineLength($length) ->setIsNewFile($is_new) ->setContent($text) ->save(); $view = new DifferentialInlineCommentView(); $view->setInlineComment($inline); $view->setOnRight($on_right); $view->setBuildScaffolding(true); $view->setMarkupEngine($engine); $view->setHandles($handles); return id(new AphrontAjaxResponse()) ->setContent( array( 'inlineCommentID' => $inline->getID(), 'markup' => $view->render(), )); default: $dialog = new AphrontDialogView(); $dialog->setUser($user); $dialog->setTitle('New Inline Comment'); $dialog->setSubmitURI($submit_uri); $dialog->addHiddenInput('op', 'create'); $dialog->addHiddenInput('changeset', $changeset); $dialog->addHiddenInput('is_new', $is_new); $dialog->addHiddenInput('on_right', $on_right); $dialog->addHiddenInput('number', $number); $dialog->addHiddenInput('length', $length); $dialog->addSubmitButton(); $dialog->addCancelButton('#'); $dialog->appendChild(''); return id(new AphrontDialogResponse())->setDialog($dialog); } } }