1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-16 03:42:41 +01:00
phorge-phorge/src/applications/differential/customfield/DifferentialSubscribersField.php
Joshua Spence 97a8700e45 Rename PHIDType classes
Summary: Ref T5655. Rename `PhabricatorPHIDType` subclasses for clarity (see discussion in D9839). I'm not too keen on some of the resulting class names, so feel free to suggest alternatives.

Test Plan: Ran unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, hach-que

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D9986
2014-07-24 08:05:46 +10:00

96 lines
2.2 KiB
PHP

<?php
final class DifferentialSubscribersField
extends DifferentialCoreCustomField {
public function getFieldKey() {
return 'differential:subscribers';
}
public function getFieldKeyForConduit() {
return 'ccPHIDs';
}
public function getFieldName() {
return pht('Subscribers');
}
public function getFieldDescription() {
return pht('Manage subscribers.');
}
protected function readValueFromRevision(
DifferentialRevision $revision) {
if (!$revision->getPHID()) {
return array();
}
return PhabricatorSubscribersQuery::loadSubscribersForPHID(
$revision->getPHID());
}
public function getNewValueForApplicationTransactions() {
return array('=' => $this->getValue());
}
public function readValueFromRequest(AphrontRequest $request) {
$this->setValue($request->getArr($this->getFieldKey()));
}
public function getRequiredHandlePHIDsForEdit() {
return $this->getValue();
}
public function renderEditControl(array $handles) {
return id(new AphrontFormTokenizerControl())
->setName($this->getFieldKey())
->setDatasource(new PhabricatorMetaMTAMailableDatasource())
->setValue($handles)
->setError($this->getFieldError())
->setLabel($this->getFieldName());
}
public function getApplicationTransactionType() {
return PhabricatorTransactions::TYPE_SUBSCRIBERS;
}
public function shouldAppearInCommitMessage() {
return true;
}
public function shouldAllowEditInCommitMessage() {
return true;
}
public function shouldAppearInCommitMessageTemplate() {
return true;
}
public function getCommitMessageLabels() {
return array(
'CC',
'CCs',
'Subscriber',
'Subscribers',
);
}
public function parseValueFromCommitMessage($value) {
return $this->parseObjectList(
$value,
array(
PhabricatorPeopleUserPHIDType::TYPECONST,
PhabricatorProjectProjectPHIDType::TYPECONST,
PhabricatorMailingListListPHIDType::TYPECONST,
));
}
public function getRequiredHandlePHIDsForCommitMessage() {
return $this->getValue();
}
public function renderCommitMessageValue(array $handles) {
return $this->renderObjectList($handles);
}
}