I want to add a new Bug: field to arc diff.
I've been trying to do so by subclassing DifferentialCustomField but it's not clear which are the minimum methods I need to implement to have it work.
An example or user guide would be very helpful.
I want to add a new Bug: field to arc diff.
I've been trying to do so by subclassing DifferentialCustomField but it's not clear which are the minimum methods I need to implement to have it work.
An example or user guide would be very helpful.
This is my current code, copied shamelessly from DifferentialJiraIssuesField.php
It renders the field on arc diff but doesn't save the values provided. Any help would be appreciated.
<?php final class IDDiffBugCustomField extends DifferentialStoredCustomField { private $error; public function getFieldKey() { return 'ideadevice:bugid'; } public function getFieldName() { return pht('Bug'); } public function renderPropertyViewLabel() { return pht('Bug'); } public function getFieldDescription() { return 'bug id for this review'; } public function shouldAppearInPropertyView() { // This is required or the field won't be loaded on the detail page. return true; } public function shouldAppearInEditView() { return true; } public function renderPropertyViewValue(array $handles) { $value = $this->getValue(); $links = array(); foreach ($value as $v) { $links[] = phutil_tag( 'a', array( 'href' => 'https://bug.example.com/issue/' + $v ), pht($v)); } return phutil_implode_html(phutil_tag('br'), $links); } public function renderEditControl(array $handles) { return id(new AphrontFormTextControl()) ->setLabel(pht('Bug')) ->setCaption( pht('Example: %s', phutil_tag('tt', array(), '#c-3, #e3-9'))) ->setName($this->getFieldKey()) ->setValue(implode(', ', nonempty($this->getValue(), array()))) ->setError($this->error); } /* public function getValueForStorage() { */ /* return json_encode($this->getValue()); */ /* } */ /* public function setValueFromStorage($value) { */ /* try { */ /* $this->setValue(phutil_json_decode($value)); */ /* } catch (PhutilJSONParserException $ex) { */ /* $this->setValue(array()); */ /* } */ /* return $this; */ /* } */ public function shouldAppearInCommitMessage() { return true; } public function shouldAppearInCommitMessageTemplate() { return true; } public function getCommitMessageLabels() { return array( 'bug', 'bugid', 'issue', 'refs', ); } public function parseValueFromCommitMessage($value) { return preg_split('/[\s,]+/', $value, $limit = -1, PREG_SPLIT_NO_EMPTY); } public function readValueFromCommitMessage($value) { $this->setValue($value); return $this; } public function renderCommitMessageValue(array $handles) { $value = $this->getValue(); if (!$value) { return null; } return implode(', ', $value); } }