Differential D17066 Diff 41082 src/applications/differential/field/DifferentialTitleCommitMessageField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/field/DifferentialTitleCommitMessageField.php
| <?php | <?php | ||||
| final class DifferentialTitleCommitMessageField | final class DifferentialTitleCommitMessageField | ||||
| extends DifferentialCommitMessageField { | extends DifferentialCommitMessageField { | ||||
| const FIELDKEY = 'title'; | const FIELDKEY = 'title'; | ||||
| public function getFieldName() { | public function getFieldName() { | ||||
| return pht('Title'); | return pht('Title'); | ||||
| } | } | ||||
| public function getFieldOrder() { | |||||
| return 1000; | |||||
| } | |||||
| public static function getDefaultTitle() { | public static function getDefaultTitle() { | ||||
| return pht('<<Replace this line with your revision title>'); | return pht('<<Replace this line with your revision title>'); | ||||
| } | } | ||||
| public function parseFieldValue($value) { | public function parseFieldValue($value) { | ||||
| if ($value === self::getDefaultTitle()) { | if ($value === self::getDefaultTitle()) { | ||||
| $this->raiseParseException( | $this->raiseParseException( | ||||
| pht( | pht( | ||||
| 'Replace the default title line with a human-readable revision '. | 'Replace the default title line with a human-readable revision '. | ||||
| 'title which describes the changes you are making.')); | 'title which describes the changes you are making.')); | ||||
| } | } | ||||
| return parent::parseFieldValue($value); | return parent::parseFieldValue($value); | ||||
| } | } | ||||
| public function validateFieldValue($value) { | public function validateFieldValue($value) { | ||||
| if (!strlen($value)) { | if (!strlen($value)) { | ||||
| $this->raiseValidationException( | $this->raiseValidationException( | ||||
| pht( | pht( | ||||
| 'You must provide a revision title in the first line '. | 'You must provide a revision title in the first line '. | ||||
| 'of your commit message.')); | 'of your commit message.')); | ||||
| } | } | ||||
| } | } | ||||
| public function readFieldValueFromObject(DifferentialRevision $revision) { | |||||
| $value = $revision->getTitle(); | |||||
| if (!strlen($value)) { | |||||
| return self::getDefaultTitle(); | |||||
| } | |||||
| return $value; | |||||
| } | |||||
| } | } | ||||