forked from llvm/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorDiffInlineCommentContentState.php
69 lines (51 loc) · 1.69 KB
/
PhabricatorDiffInlineCommentContentState.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
final class PhabricatorDiffInlineCommentContentState
extends PhabricatorInlineCommentContentState {
private $hasSuggestion = false;
private $suggestionText = '';
public function isEmptyContentState() {
if (!parent::isEmptyContentState()) {
return false;
}
if ($this->getContentHasSuggestion()) {
if (strlen($this->getContentSuggestionText())) {
return false;
}
}
return true;
}
public function setContentSuggestionText($suggestion_text) {
$this->suggestionText = $suggestion_text;
return $this;
}
public function getContentSuggestionText() {
return $this->suggestionText;
}
public function setContentHasSuggestion($has_suggestion) {
$this->hasSuggestion = $has_suggestion;
return $this;
}
public function getContentHasSuggestion() {
return $this->hasSuggestion;
}
public function newStorageMap() {
return parent::writeStorageMap() + array(
'hasSuggestion' => $this->getContentHasSuggestion(),
'suggestionText' => $this->getContentSuggestionText(),
);
}
public function readStorageMap(array $map) {
$result = parent::readStorageMap($map);
$has_suggestion = (bool)idx($map, 'hasSuggestion');
$this->setContentHasSuggestion($has_suggestion);
$suggestion_text = (string)idx($map, 'suggestionText');
$this->setContentSuggestionText($suggestion_text);
return $result;
}
protected function newStorageMapFromRequest(AphrontRequest $request) {
$map = parent::newStorageMapFromRequest($request);
$map['hasSuggestion'] = (bool)$request->getBool('hasSuggestion');
$map['suggestionText'] = (string)$request->getStr('suggestionText');
return $map;
}
}