@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 69 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorDiffInlineCommentContentState 4 extends PhabricatorInlineCommentContentState { 5 6 private $hasSuggestion = false; 7 private $suggestionText = ''; 8 9 public function isEmptyContentState() { 10 if (!parent::isEmptyContentState()) { 11 return false; 12 } 13 14 if ($this->getContentHasSuggestion()) { 15 if (strlen($this->getContentSuggestionText())) { 16 return false; 17 } 18 } 19 20 return true; 21 } 22 23 public function setContentSuggestionText($suggestion_text) { 24 $this->suggestionText = $suggestion_text; 25 return $this; 26 } 27 28 public function getContentSuggestionText() { 29 return $this->suggestionText; 30 } 31 32 public function setContentHasSuggestion($has_suggestion) { 33 $this->hasSuggestion = $has_suggestion; 34 return $this; 35 } 36 37 public function getContentHasSuggestion() { 38 return $this->hasSuggestion; 39 } 40 41 public function newStorageMap() { 42 return parent::writeStorageMap() + array( 43 'hasSuggestion' => $this->getContentHasSuggestion(), 44 'suggestionText' => $this->getContentSuggestionText(), 45 ); 46 } 47 48 public function readStorageMap(array $map) { 49 $result = parent::readStorageMap($map); 50 51 $has_suggestion = (bool)idx($map, 'hasSuggestion'); 52 $this->setContentHasSuggestion($has_suggestion); 53 54 $suggestion_text = (string)idx($map, 'suggestionText'); 55 $this->setContentSuggestionText($suggestion_text); 56 57 return $result; 58 } 59 60 protected function newStorageMapFromRequest(AphrontRequest $request) { 61 $map = parent::newStorageMapFromRequest($request); 62 63 $map['hasSuggestion'] = (bool)$request->getBool('hasSuggestion'); 64 $map['suggestionText'] = (string)$request->getStr('suggestionText'); 65 66 return $map; 67 } 68 69}