Differential D17066 Diff 41082 src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
| <?php | <?php | ||||
| final class DifferentialRevisionIDCommitMessageField | final class DifferentialRevisionIDCommitMessageField | ||||
| extends DifferentialCommitMessageField { | extends DifferentialCommitMessageField { | ||||
| const FIELDKEY = 'revisionID'; | const FIELDKEY = 'revisionID'; | ||||
| public function getFieldName() { | public function getFieldName() { | ||||
| return pht('Differential Revision'); | return pht('Differential Revision'); | ||||
| } | } | ||||
| public function getFieldOrder() { | |||||
| return 200000; | |||||
| } | |||||
| public function isTemplateField() { | |||||
| return false; | |||||
| } | |||||
| public function parseFieldValue($value) { | public function parseFieldValue($value) { | ||||
| // If the value is just "D123" or similar, parse the ID from it directly. | // If the value is just "D123" or similar, parse the ID from it directly. | ||||
| $value = trim($value); | $value = trim($value); | ||||
| $matches = null; | $matches = null; | ||||
| if (preg_match('/^[dD]([1-9]\d*)\z/', $value, $matches)) { | if (preg_match('/^[dD]([1-9]\d*)\z/', $value, $matches)) { | ||||
| return (int)$matches[1]; | return (int)$matches[1]; | ||||
| } | } | ||||
| Show All 24 Lines | if (preg_match('#^/D(\d+)$#', $path, $matches)) { | ||||
| return $id; | return $id; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function readFieldValueFromObject(DifferentialRevision $revision) { | |||||
| return $revision->getID(); | |||||
| } | |||||
| public function readFieldValueFromConduit($value) { | |||||
| if (is_int($value)) { | |||||
| $value = (string)$value; | |||||
| } | |||||
| return $this->readStringFieldValueFromConduit($value); | |||||
| } | |||||
| public function renderFieldValue($value) { | |||||
| if (!strlen($value)) { | |||||
| return null; | |||||
| } | |||||
| return PhabricatorEnv::getProductionURI('/D'.$value); | |||||
| } | |||||
| } | } | ||||