Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentController.php
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | abstract class PhabricatorInlineCommentController | ||||
| public function getCommentID() { | public function getCommentID() { | ||||
| return $this->commentID; | return $this->commentID; | ||||
| } | } | ||||
| public function getOperation() { | public function getOperation() { | ||||
| return $this->operation; | return $this->operation; | ||||
| } | } | ||||
| public function getCommentText() { | |||||
| return $this->commentText; | |||||
| } | |||||
| public function getLineLength() { | public function getLineLength() { | ||||
| return $this->lineLength; | return $this->lineLength; | ||||
| } | } | ||||
| public function getLineNumber() { | public function getLineNumber() { | ||||
| return $this->lineNumber; | return $this->lineNumber; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | switch ($op) { | ||||
| case 'draft': | case 'draft': | ||||
| $inline = $this->loadCommentByIDForEdit($this->getCommentID()); | $inline = $this->loadCommentByIDForEdit($this->getCommentID()); | ||||
| $versioned_draft = PhabricatorVersionedDraft::loadOrCreateDraft( | $versioned_draft = PhabricatorVersionedDraft::loadOrCreateDraft( | ||||
| $inline->getPHID(), | $inline->getPHID(), | ||||
| $viewer->getPHID(), | $viewer->getPHID(), | ||||
| $inline->getID()); | $inline->getID()); | ||||
| $map = $this->getContentState(); | $map = $this->newRequestContentState($inline)->newStorageMap(); | ||||
| foreach ($map as $key => $value) { | $versioned_draft->setProperty('inline.state', $map); | ||||
| $versioned_draft->setProperty($key, $value); | |||||
| } | |||||
| $versioned_draft->save(); | $versioned_draft->save(); | ||||
| // We have to synchronize the draft engine after saving a versioned | // We have to synchronize the draft engine after saving a versioned | ||||
| // draft, because taking an inline comment from "no text, no draft" | // draft, because taking an inline comment from "no text, no draft" | ||||
| // to "no text, text in a draft" marks the container object as having | // to "no text, text in a draft" marks the container object as having | ||||
| // a draft. | // a draft. | ||||
| $draft_engine = $this->newDraftEngine(); | $draft_engine = $this->newDraftEngine(); | ||||
| if ($draft_engine) { | if ($draft_engine) { | ||||
| ▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | private function loadCommentByQuery( | ||||
| return $inline; | return $inline; | ||||
| } | } | ||||
| private function hasContentState() { | private function hasContentState() { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| return (bool)$request->getBool('hasContentState'); | return (bool)$request->getBool('hasContentState'); | ||||
| } | } | ||||
| private function getContentState() { | private function newRequestContentState($inline) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| return $inline->newContentStateFromRequest($request); | |||||
| $comment_text = $request->getStr('text'); | |||||
| return array( | |||||
| 'inline.text' => (string)$comment_text, | |||||
| ); | |||||
| } | } | ||||
| private function updateCommentContentState(PhabricatorInlineComment $inline) { | private function updateCommentContentState(PhabricatorInlineComment $inline) { | ||||
| if (!$this->hasContentState()) { | if (!$this->hasContentState()) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Attempting to update comment content state, but request has no '. | 'Attempting to update comment content state, but request has no '. | ||||
| 'content state.')); | 'content state.')); | ||||
| } | } | ||||
| $state = $this->getContentState(); | $state = $this->newRequestContentState($inline); | ||||
| $inline->setContentState($state); | |||||
| $text = $state['inline.text']; | |||||
| $inline->setContent($text); | |||||
| } | } | ||||
| private function saveComment(PhabricatorInlineComment $inline) { | private function saveComment(PhabricatorInlineComment $inline) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $draft_engine = $this->newDraftEngine(); | $draft_engine = $this->newDraftEngine(); | ||||
| $inline->openTransaction(); | $inline->openTransaction(); | ||||
| $inline->save(); | $inline->save(); | ||||
| Show All 26 Lines | |||||