[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialInlineComment 4 implements PhabricatorInlineCommentInterface { 5 6 private $proxy; 7 private $syntheticAuthor; 8 9 public function __construct() { 10 $this->proxy = new DifferentialTransactionComment(); 11 } 12 13 public function __clone() { 14 $this->proxy = clone $this->proxy; 15 } 16 17 public function getTransactionCommentForSave() { 18 $content_source = PhabricatorContentSource::newForSource( 19 PhabricatorContentSource::SOURCE_LEGACY, 20 array()); 21 22 $this->proxy 23 ->setViewPolicy('public') 24 ->setEditPolicy($this->getAuthorPHID()) 25 ->setContentSource($content_source) 26 ->setCommentVersion(1); 27 28 return $this->proxy; 29 } 30 31 public function openTransaction() { 32 $this->proxy->openTransaction(); 33 } 34 35 public function saveTransaction() { 36 $this->proxy->saveTransaction(); 37 } 38 39 public function save() { 40 $this->getTransactionCommentForSave()->save(); 41 42 return $this; 43 } 44 45 public function delete() { 46 $this->proxy->delete(); 47 48 return $this; 49 } 50 51 public function getID() { 52 return $this->proxy->getID(); 53 } 54 55 public function getPHID() { 56 return $this->proxy->getPHID(); 57 } 58 59 public static function newFromModernComment( 60 DifferentialTransactionComment $comment) { 61 62 $obj = new DifferentialInlineComment(); 63 $obj->proxy = $comment; 64 65 return $obj; 66 } 67 68 public function setSyntheticAuthor($synthetic_author) { 69 $this->syntheticAuthor = $synthetic_author; 70 return $this; 71 } 72 73 public function getSyntheticAuthor() { 74 return $this->syntheticAuthor; 75 } 76 77 public function isCompatible(PhabricatorInlineCommentInterface $comment) { 78 return 79 ($this->getAuthorPHID() === $comment->getAuthorPHID()) && 80 ($this->getSyntheticAuthor() === $comment->getSyntheticAuthor()) && 81 ($this->getContent() === $comment->getContent()); 82 } 83 84 public function setContent($content) { 85 $this->proxy->setContent($content); 86 return $this; 87 } 88 89 public function getContent() { 90 return $this->proxy->getContent(); 91 } 92 93 public function isDraft() { 94 return !$this->proxy->getTransactionPHID(); 95 } 96 97 public function setChangesetID($id) { 98 $this->proxy->setChangesetID($id); 99 return $this; 100 } 101 102 public function getChangesetID() { 103 return $this->proxy->getChangesetID(); 104 } 105 106 public function setIsNewFile($is_new) { 107 $this->proxy->setIsNewFile($is_new); 108 return $this; 109 } 110 111 public function getIsNewFile() { 112 return $this->proxy->getIsNewFile(); 113 } 114 115 public function setLineNumber($number) { 116 $this->proxy->setLineNumber($number); 117 return $this; 118 } 119 120 public function getLineNumber() { 121 return $this->proxy->getLineNumber(); 122 } 123 124 public function setLineLength($length) { 125 $this->proxy->setLineLength($length); 126 return $this; 127 } 128 129 public function getLineLength() { 130 return $this->proxy->getLineLength(); 131 } 132 133 public function setCache($cache) { 134 return $this; 135 } 136 137 public function getCache() { 138 return null; 139 } 140 141 public function setAuthorPHID($phid) { 142 $this->proxy->setAuthorPHID($phid); 143 return $this; 144 } 145 146 public function getAuthorPHID() { 147 return $this->proxy->getAuthorPHID(); 148 } 149 150 public function setRevision(DifferentialRevision $revision) { 151 $this->proxy->setRevisionPHID($revision->getPHID()); 152 return $this; 153 } 154 155 public function getRevisionPHID() { 156 return $this->proxy->getRevisionPHID(); 157 } 158 159 // Although these are purely transitional, they're also *extra* dumb. 160 161 public function setRevisionID($revision_id) { 162 $revision = id(new DifferentialRevision())->load($revision_id); 163 return $this->setRevision($revision); 164 } 165 166 public function getRevisionID() { 167 $phid = $this->proxy->getRevisionPHID(); 168 if (!$phid) { 169 return null; 170 } 171 172 $revision = id(new DifferentialRevision())->loadOneWhere( 173 'phid = %s', 174 $phid); 175 if (!$revision) { 176 return null; 177 } 178 return $revision->getID(); 179 } 180 181 // When setting a comment ID, we also generate a phantom transaction PHID for 182 // the future transaction. 183 184 public function setCommentID($id) { 185 $this->proxy->setTransactionPHID( 186 PhabricatorPHID::generateNewPHID( 187 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST, 188 DifferentialRevisionPHIDType::TYPECONST)); 189 return $this; 190 } 191 192 /* -( PhabricatorMarkupInterface Implementation )-------------------------- */ 193 194 195 public function getMarkupFieldKey($field) { 196 // We can't use ID because synthetic comments don't have it. 197 return 'DI:'.PhabricatorHash::digest($this->getContent()); 198 } 199 200 public function newMarkupEngine($field) { 201 return PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 202 } 203 204 public function getMarkupText($field) { 205 return $this->getContent(); 206 } 207 208 public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { 209 return $output; 210 } 211 212 public function shouldUseMarkupCache($field) { 213 // Only cache submitted comments. 214 return ($this->getID() && !$this->isDraft()); 215 } 216 217 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |