2015-11-29 10:05:41 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectsEditEngineExtension
|
|
|
|
extends PhabricatorEditEngineExtension {
|
|
|
|
|
|
|
|
const EXTENSIONKEY = 'projects.projects';
|
|
|
|
|
|
|
|
public function getExtensionPriority() {
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isExtensionEnabled() {
|
|
|
|
return PhabricatorApplication::isClassInstalled(
|
|
|
|
'PhabricatorProjectApplication');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getExtensionName() {
|
|
|
|
return pht('Projects');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function supportsObject(
|
|
|
|
PhabricatorEditEngine $engine,
|
|
|
|
PhabricatorApplicationTransactionInterface $object) {
|
|
|
|
|
|
|
|
return ($object instanceof PhabricatorProjectInterface);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildCustomEditFields(
|
|
|
|
PhabricatorEditEngine $engine,
|
|
|
|
PhabricatorApplicationTransactionInterface $object) {
|
|
|
|
|
|
|
|
$edge_type = PhabricatorTransactions::TYPE_EDGE;
|
|
|
|
$project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
|
|
|
|
|
|
|
$object_phid = $object->getPHID();
|
|
|
|
if ($object_phid) {
|
|
|
|
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
|
|
$object_phid,
|
|
|
|
$project_edge_type);
|
|
|
|
$project_phids = array_reverse($project_phids);
|
|
|
|
} else {
|
|
|
|
$project_phids = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$projects_field = id(new PhabricatorProjectsEditField())
|
|
|
|
->setKey('projectPHIDs')
|
|
|
|
->setLabel(pht('Projects'))
|
|
|
|
->setEditTypeKey('projects')
|
|
|
|
->setAliases(array('project', 'projects'))
|
2015-12-07 11:37:51 -08:00
|
|
|
->setIsCopyable(true)
|
2015-11-29 13:24:47 -08:00
|
|
|
->setUseEdgeTransactions(true)
|
2015-12-15 06:57:32 -08:00
|
|
|
->setCommentActionLabel(pht('Change Projects'))
|
2015-12-16 05:09:21 -08:00
|
|
|
->setDescription(pht('Select projects for the object.'))
|
2015-11-29 10:05:41 -08:00
|
|
|
->setTransactionType($edge_type)
|
|
|
|
->setMetadataValue('edge:type', $project_edge_type)
|
|
|
|
->setValue($project_phids);
|
|
|
|
|
2015-12-16 05:09:21 -08:00
|
|
|
$projects_field->setViewer($engine->getViewer());
|
|
|
|
|
|
|
|
$edit_add = $projects_field->getConduitEditType('projects.add')
|
|
|
|
->setConduitDescription(pht('Add projects.'));
|
|
|
|
|
|
|
|
$edit_set = $projects_field->getConduitEditType('projects.set')
|
|
|
|
->setConduitDescription(
|
|
|
|
pht('Set projects, overwriting current value.'));
|
|
|
|
|
|
|
|
$edit_rem = $projects_field->getConduitEditType('projects.remove')
|
|
|
|
->setConduitDescription(pht('Remove projects.'));
|
|
|
|
|
2015-11-29 10:05:41 -08:00
|
|
|
return array(
|
|
|
|
$projects_field,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|