Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/interface/PhabricatorInlineComment.php
| Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | if (!array_key_exists($key, $this->versionedDrafts)) { | ||||
| 'Versioned draft is not attached for user with fragment "%s".', | 'Versioned draft is not attached for user with fragment "%s".', | ||||
| $key)); | $key)); | ||||
| } | } | ||||
| return $this->versionedDrafts[$key]; | return $this->versionedDrafts[$key]; | ||||
| } | } | ||||
| public function isVoidComment(PhabricatorUser $viewer) { | public function isVoidComment(PhabricatorUser $viewer) { | ||||
| return !strlen($this->getContentForEdit($viewer)); | return $this->getContentStateForEdit($viewer)->isEmptyContentState(); | ||||
| } | } | ||||
| public function getContentForEdit(PhabricatorUser $viewer) { | public function getContentStateForEdit(PhabricatorUser $viewer) { | ||||
| $content = $this->getContent(); | $state = $this->getContentState(); | ||||
| if (!$this->hasVersionedDraftForViewer($viewer)) { | if ($this->hasVersionedDraftForViewer($viewer)) { | ||||
| return $content; | $versioned_draft = $this->getVersionedDraftForViewer($viewer); | ||||
| if ($versioned_draft) { | |||||
| $storage_map = $versioned_draft->getProperty('inline.state'); | |||||
| if (is_array($storage_map)) { | |||||
| $state->readStorageMap($storage_map); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| $versioned_draft = $this->getVersionedDraftForViewer($viewer); | return $state; | ||||
| if (!$versioned_draft) { | |||||
| return $content; | |||||
| } | } | ||||
| $draft_text = $versioned_draft->getProperty('inline.text'); | protected function newContentState() { | ||||
| if ($draft_text === null) { | return new PhabricatorDiffInlineCommentContentState(); | ||||
| return $content; | |||||
| } | } | ||||
| return $draft_text; | public function newContentStateFromRequest(AphrontRequest $request) { | ||||
| return $this->newContentState()->readFromRequest($request); | |||||
| } | } | ||||
| public function getContentState() { | public function getContentState() { | ||||
| return array( | $state = $this->newContentState(); | ||||
| 'text' => $this->getContent(), | |||||
| ); | $storage = $this->getStorageObject(); | ||||
| $storage_map = $storage->getAttribute('inline.state'); | |||||
| if (is_array($storage_map)) { | |||||
| $state->readStorageMap($storage_map); | |||||
| } | |||||
| $state->setContentText($this->getContent()); | |||||
| return $state; | |||||
| } | } | ||||
| public function setContentState(PhabricatorInlineCommentContentState $state) { | |||||
| $storage = $this->getStorageObject(); | |||||
| $storage_map = $state->newStorageMap(); | |||||
| $storage->setAttribute('inline.state', $storage_map); | |||||
| $this->setContent($state->getContentText()); | |||||
| return $this; | |||||
| } | |||||
| /* -( PhabricatorMarkupInterface Implementation )-------------------------- */ | /* -( PhabricatorMarkupInterface Implementation )-------------------------- */ | ||||
| public function getMarkupFieldKey($field) { | public function getMarkupFieldKey($field) { | ||||
| $content = $this->getMarkupText($field); | $content = $this->getMarkupText($field); | ||||
| return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); | return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); | ||||
| } | } | ||||
| Show All 17 Lines | |||||