Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / engineextension / PhabricatorProjectsEditEngineExtension.php
bloba388a39a97deb1bf6109e3eae1405b572f231c06
1 <?php
3 final class PhabricatorProjectsEditEngineExtension
4 extends PhabricatorEditEngineExtension {
6 const EXTENSIONKEY = 'projects.projects';
8 const EDITKEY_ADD = 'projects.add';
9 const EDITKEY_SET = 'projects.set';
10 const EDITKEY_REMOVE = 'projects.remove';
12 public function getExtensionPriority() {
13 return 500;
16 public function isExtensionEnabled() {
17 return PhabricatorApplication::isClassInstalled(
18 'PhabricatorProjectApplication');
21 public function getExtensionName() {
22 return pht('Projects');
25 public function supportsObject(
26 PhabricatorEditEngine $engine,
27 PhabricatorApplicationTransactionInterface $object) {
29 return ($object instanceof PhabricatorProjectInterface);
32 public function buildCustomEditFields(
33 PhabricatorEditEngine $engine,
34 PhabricatorApplicationTransactionInterface $object) {
36 $edge_type = PhabricatorTransactions::TYPE_EDGE;
37 $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
39 $object_phid = $object->getPHID();
40 if ($object_phid) {
41 $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
42 $object_phid,
43 $project_edge_type);
44 $project_phids = array_reverse($project_phids);
45 } else {
46 $project_phids = array();
49 $viewer = $engine->getViewer();
51 $projects_field = id(new PhabricatorProjectsEditField())
52 ->setKey('projectPHIDs')
53 ->setLabel(pht('Tags'))
54 ->setEditTypeKey('projects')
55 ->setAliases(array('project', 'projects', 'tag', 'tags'))
56 ->setIsCopyable(true)
57 ->setUseEdgeTransactions(true)
58 ->setCommentActionLabel(pht('Change Project Tags'))
59 ->setCommentActionOrder(8000)
60 ->setDescription(pht('Select project tags for the object.'))
61 ->setTransactionType($edge_type)
62 ->setMetadataValue('edge:type', $project_edge_type)
63 ->setValue($project_phids)
64 ->setViewer($viewer);
66 $projects_datasource = id(new PhabricatorProjectDatasource())
67 ->setViewer($viewer);
69 $edit_add = $projects_field->getConduitEditType(self::EDITKEY_ADD)
70 ->setConduitDescription(pht('Add project tags.'));
72 $edit_set = $projects_field->getConduitEditType(self::EDITKEY_SET)
73 ->setConduitDescription(
74 pht('Set project tags, overwriting current value.'));
76 $edit_rem = $projects_field->getConduitEditType(self::EDITKEY_REMOVE)
77 ->setConduitDescription(pht('Remove project tags.'));
79 $projects_field->getBulkEditType(self::EDITKEY_ADD)
80 ->setBulkEditLabel(pht('Add project tags'))
81 ->setDatasource($projects_datasource);
83 $projects_field->getBulkEditType(self::EDITKEY_SET)
84 ->setBulkEditLabel(pht('Set project tags to'))
85 ->setDatasource($projects_datasource);
87 $projects_field->getBulkEditType(self::EDITKEY_REMOVE)
88 ->setBulkEditLabel(pht('Remove project tags'))
89 ->setDatasource($projects_datasource);
91 return array(
92 $projects_field,