Differential D17207 Diff 41374 src/applications/differential/customfield/DifferentialCustomField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/customfield/DifferentialCustomField.php
| <?php | <?php | ||||
| /** | /** | ||||
| * @task commitmessage Integration with Commit Messages | * @task commitmessage Integration with Commit Messages | ||||
| * @task diff Integration with Diff Properties | * @task diff Integration with Diff Properties | ||||
| */ | */ | ||||
| abstract class DifferentialCustomField | abstract class DifferentialCustomField | ||||
| extends PhabricatorCustomField { | extends PhabricatorCustomField { | ||||
| const ROLE_COMMITMESSAGE = 'differential:commitmessage'; | |||||
| const ROLE_COMMITMESSAGEEDIT = 'differential:commitmessageedit'; | |||||
| /** | /** | ||||
| * TODO: It would be nice to remove this, but a lot of different code is | * TODO: It would be nice to remove this, but a lot of different code is | ||||
| * bound together by it. Until everything is modernized, retaining the old | * bound together by it. Until everything is modernized, retaining the old | ||||
| * field keys is the only reasonable way to update things one piece | * field keys is the only reasonable way to update things one piece | ||||
| * at a time. | * at a time. | ||||
| */ | */ | ||||
| public function getFieldKeyForConduit() { | public function getFieldKeyForConduit() { | ||||
| return $this->getFieldKey(); | return $this->getFieldKey(); | ||||
| } | } | ||||
| // TODO: As above. | // TODO: As above. | ||||
| public function getModernFieldKey() { | public function getModernFieldKey() { | ||||
| return $this->getFieldKeyForConduit(); | return $this->getFieldKeyForConduit(); | ||||
| } | } | ||||
| public function shouldEnableForRole($role) { | |||||
| switch ($role) { | |||||
| case self::ROLE_COMMITMESSAGE: | |||||
| return $this->shouldAppearInCommitMessage(); | |||||
| case self::ROLE_COMMITMESSAGEEDIT: | |||||
| return $this->shouldAppearInCommitMessage() && | |||||
| $this->shouldAllowEditInCommitMessage(); | |||||
| } | |||||
| return parent::shouldEnableForRole($role); | |||||
| } | |||||
| protected function parseObjectList( | protected function parseObjectList( | ||||
| $value, | $value, | ||||
| array $types, | array $types, | ||||
| $allow_partial = false, | $allow_partial = false, | ||||
| array $suffixes = array()) { | array $suffixes = array()) { | ||||
| return id(new PhabricatorObjectListQuery()) | return id(new PhabricatorObjectListQuery()) | ||||
| ->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
| ->setAllowedTypes($types) | ->setAllowedTypes($types) | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| /* -( Integration with Commit Messages )----------------------------------- */ | /* -( Integration with Commit Messages )----------------------------------- */ | ||||
| /** | /** | ||||
| * @task commitmessage | * @task commitmessage | ||||
| */ | */ | ||||
| public function shouldAppearInCommitMessage() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->shouldAppearInCommitMessage(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function shouldAppearInCommitMessageTemplate() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->shouldAppearInCommitMessageTemplate(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function shouldAllowEditInCommitMessage() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->shouldAllowEditInCommitMessage(); | |||||
| } | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function getProTips() { | public function getProTips() { | ||||
| if ($this->getProxy()) { | if ($this->getProxy()) { | ||||
| return $this->getProxy()->getProTips(); | return $this->getProxy()->getProTips(); | ||||
| } | } | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function getCommitMessageLabels() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->getCommitMessageLabels(); | |||||
| } | |||||
| return array($this->renderCommitMessageLabel()); | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function parseValueFromCommitMessage($value) { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->parseValueFromCommitMessage($value); | |||||
| } | |||||
| return $value; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function readValueFromCommitMessage($value) { | |||||
| if ($this->getProxy()) { | |||||
| $this->getProxy()->readValueFromCommitMessage($value); | |||||
| return $this; | |||||
| } | |||||
| return $this; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function shouldOverwriteWhenCommitMessageIsEdited() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->shouldOverwriteWhenCommitMessageIsEdited(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function getRequiredHandlePHIDsForCommitMessage() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->getRequiredHandlePHIDsForCommitMessage(); | |||||
| } | |||||
| return array(); | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function renderCommitMessageLabel() { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->renderCommitMessageLabel(); | |||||
| } | |||||
| return $this->getFieldName(); | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function renderCommitMessageValue(array $handles) { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->renderCommitMessageValue($handles); | |||||
| } | |||||
| throw new PhabricatorCustomFieldImplementationIncompleteException($this); | |||||
| } | |||||
| /** | |||||
| * @task commitmessage | |||||
| */ | |||||
| public function validateCommitMessageValue($value) { | |||||
| if ($this->getProxy()) { | |||||
| return $this->getProxy()->validateCommitMessageValue($value); | |||||
| } | |||||
| return; | |||||
| } | |||||
| /* -( Integration with Diff Properties )----------------------------------- */ | /* -( Integration with Diff Properties )----------------------------------- */ | ||||
| /** | /** | ||||
| * @task diff | * @task diff | ||||
| */ | */ | ||||
| public function shouldAppearInDiffPropertyView() { | public function shouldAppearInDiffPropertyView() { | ||||
| if ($this->getProxy()) { | if ($this->getProxy()) { | ||||
| Show All 28 Lines | |||||