3 abstract class ReleephFieldSpecification
4 extends PhabricatorCustomField
5 implements PhabricatorMarkupInterface
{
7 // TODO: This is temporary, until ReleephFieldSpecification is more conformant
8 // to PhabricatorCustomField.
11 public function readValueFromRequest(AphrontRequest
$request) {
12 $this->requestValue
= $request->getStr($this->getRequiredStorageKey());
16 public function shouldAppearInPropertyView() {
20 public function renderPropertyViewLabel() {
21 return $this->getName();
24 public function renderPropertyViewValue(array $handles) {
25 $key = $this->getRequiredStorageKey();
26 $value = $this->getReleephRequest()->getDetail($key);
33 abstract public function getName();
35 /* -( Storage )------------------------------------------------------------ */
37 public function getStorageKey() {
41 public function getRequiredStorageKey() {
42 $key = $this->getStorageKey();
44 throw new PhabricatorCustomFieldImplementationIncompleteException($this);
46 if (strpos($key, '.') !== false) {
48 * Storage keys are reused for form controls, and periods in form control
49 * names break HTML forms.
51 throw new Exception(pht("You can't use '%s' in storage keys!", '.'));
56 public function shouldAppearInEditView() {
57 return $this->isEditable();
60 final public function isEditable() {
61 return $this->getStorageKey() !== null;
64 final public function getValue() {
65 if ($this->requestValue
!== null) {
66 return $this->requestValue
;
69 $key = $this->getRequiredStorageKey();
70 return $this->getReleephRequest()->getDetail($key);
73 final public function setValue($value) {
74 $key = $this->getRequiredStorageKey();
75 return $this->getReleephRequest()->setDetail($key, $value);
79 * @throws ReleephFieldParseException, to show an error.
81 public function validate($value) {
86 * Turn values as they are stored in a ReleephRequest into a text that can be
87 * rendered as a transactions old/new values.
89 public function normalizeForTransactionView(
90 PhabricatorApplicationTransaction
$xaction,
97 /* -( Conduit )------------------------------------------------------------ */
99 public function getKeyForConduit() {
100 return $this->getRequiredStorageKey();
103 public function getValueForConduit() {
104 return $this->getValue();
107 public function setValueFromConduitAPIRequest(ConduitAPIRequest
$request) {
109 $request->getValue('fields', array()),
110 $this->getRequiredStorageKey());
111 $this->validate($value);
112 $this->setValue($value);
117 /* -( Arcanist )----------------------------------------------------------- */
119 public function renderHelpForArcanist() {
124 /* -( Context )------------------------------------------------------------ */
126 private $releephProject;
127 private $releephBranch;
128 private $releephRequest;
131 final public function setReleephProject(ReleephProject
$rp) {
132 $this->releephProject
= $rp;
136 final public function setReleephBranch(ReleephBranch
$rb) {
137 $this->releephRequest
= $rb;
141 final public function setReleephRequest(ReleephRequest
$rr) {
142 $this->releephRequest
= $rr;
146 final public function setUser(PhabricatorUser
$user) {
151 final public function getReleephProject() {
152 if (!$this->releephProject
) {
153 return $this->getReleephBranch()->getProduct();
155 return $this->releephProject
;
158 final public function getReleephBranch() {
159 if (!$this->releephBranch
) {
160 return $this->getReleephRequest()->getBranch();
162 return $this->releephBranch
;
165 final public function getReleephRequest() {
166 if (!$this->releephRequest
) {
167 return $this->getObject();
169 return $this->releephRequest
;
172 final public function getUser() {
174 return $this->getViewer();
179 /* -( Commit Messages )---------------------------------------------------- */
181 public function shouldAppearOnCommitMessage() {
185 public function renderLabelForCommitMessage() {
186 throw new PhabricatorCustomFieldImplementationIncompleteException($this);
189 public function renderValueForCommitMessage() {
190 throw new PhabricatorCustomFieldImplementationIncompleteException($this);
193 public function shouldAppearOnRevertMessage() {
197 public function renderLabelForRevertMessage() {
198 return $this->renderLabelForCommitMessage();
201 public function renderValueForRevertMessage() {
202 return $this->renderValueForCommitMessage();
206 /* -( Markup Interface )--------------------------------------------------- */
208 const MARKUP_FIELD_GENERIC
= 'releeph:generic-markup-field';
213 * @{class:ReleephFieldSpecification} implements much of
214 * @{interface:PhabricatorMarkupInterface} for you. If you return true from
215 * `shouldMarkup()`, and implement `getMarkupText()` then your text will be
216 * rendered through the Phabricator markup pipeline.
218 * Output is retrievable with `getMarkupEngineOutput()`.
220 public function shouldMarkup() {
224 public function getMarkupText($field) {
225 throw new PhabricatorCustomFieldImplementationIncompleteException($this);
228 final public function getMarkupEngineOutput() {
229 return $this->engine
->getOutput($this, self
::MARKUP_FIELD_GENERIC
);
232 final public function setMarkupEngine(PhabricatorMarkupEngine
$engine) {
233 $this->engine
= $engine;
234 $engine->addObject($this, self
::MARKUP_FIELD_GENERIC
);
238 final public function getMarkupFieldKey($field) {
241 $this->getReleephRequest()->getPHID(),
242 $this->getStorageKey(),
244 $this->getMarkupText($field));
246 return PhabricatorMarkupEngine
::digestRemarkupContent($this, $content);
249 final public function newMarkupEngine($field) {
250 return PhabricatorMarkupEngine
::newDifferentialMarkupEngine();
253 final public function didMarkupText(
256 PhutilMarkupEngine
$engine) {
261 final public function shouldUseMarkupCache($field) {