2014-06-23 18:49:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialProjectsField
|
|
|
|
extends DifferentialCoreCustomField {
|
|
|
|
|
|
|
|
public function getFieldKey() {
|
|
|
|
return 'phabricator:projects';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldName() {
|
2016-04-18 21:33:40 +02:00
|
|
|
return pht('Tags');
|
2014-06-23 18:49:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldDescription() {
|
|
|
|
return pht('Tag projects.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInPropertyView() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInEditView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInApplicationTransactions() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function readValueFromRevision(
|
|
|
|
DifferentialRevision $revision) {
|
|
|
|
if (!$revision->getPHID()) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
|
|
$revision->getPHID(),
|
2014-07-18 00:42:19 +02:00
|
|
|
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
2014-06-23 18:49:52 +02:00
|
|
|
$projects = array_reverse($projects);
|
|
|
|
|
|
|
|
return $projects;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getNewValueForApplicationTransactions() {
|
|
|
|
return array('=' => array_fuse($this->getValue()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function readValueFromRequest(AphrontRequest $request) {
|
|
|
|
$this->setValue($request->getArr($this->getFieldKey()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderEditControl(array $handles) {
|
|
|
|
return id(new AphrontFormTokenizerControl())
|
2015-03-31 23:10:55 +02:00
|
|
|
->setUser($this->getViewer())
|
2014-06-23 18:49:52 +02:00
|
|
|
->setName($this->getFieldKey())
|
2014-07-11 02:28:29 +02:00
|
|
|
->setDatasource(new PhabricatorProjectDatasource())
|
2015-03-31 23:10:55 +02:00
|
|
|
->setValue($this->getValue())
|
2014-06-23 18:49:52 +02:00
|
|
|
->setLabel($this->getFieldName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
|
|
|
return PhabricatorTransactions::TYPE_EDGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInCommitMessage() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAllowEditInCommitMessage() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldOverwriteWhenCommitMessageIsEdited() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommitMessageLabels() {
|
|
|
|
return array(
|
2016-04-20 03:46:17 +02:00
|
|
|
'Tags',
|
2014-06-23 18:49:52 +02:00
|
|
|
'Project',
|
|
|
|
'Projects',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDsForCommitMessage() {
|
|
|
|
return $this->getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderCommitMessageValue(array $handles) {
|
|
|
|
return $this->renderObjectList($handles);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInConduitDictionary() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionMetadata() {
|
2014-07-18 00:42:19 +02:00
|
|
|
return array(
|
|
|
|
'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
|
|
|
);
|
2014-06-23 18:49:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function parseValueFromCommitMessage($value) {
|
|
|
|
return $this->parseObjectList(
|
|
|
|
$value,
|
|
|
|
array(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorProjectProjectPHIDType::TYPECONST,
|
2014-06-23 18:49:52 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|