Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / trigger / PhabricatorProjectTriggerRemoveProjectsRule.php
blob42b6263ef6fa482b2be6bd44daf5697df618659e
1 <?php
3 final class PhabricatorProjectTriggerRemoveProjectsRule
4 extends PhabricatorProjectTriggerRule {
6 const TRIGGERTYPE = 'task.projects.remove';
8 public function getSelectControlname() {
9 return pht('Remove project tags');
12 protected function getValueForEditorField() {
13 return $this->getDatasource()->getWireTokens($this->getValue());
16 protected function assertValidRuleRecordFormat($value) {
17 if (!is_array($value)) {
18 throw new Exception(
19 pht(
20 'Remove project rule value should be a list, but is not '.
21 '(value is "%s").',
22 phutil_describe_type($value)));
26 protected function assertValidRuleRecordValue($value) {
27 if (!$value) {
28 throw new Exception(
29 pht(
30 'You must select at least one project tag to remove.'));
34 protected function newDropTransactions($object, $value) {
35 $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
37 $xaction = $object->getApplicationTransactionTemplate()
38 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
39 ->setMetadataValue('edge:type', $project_edge_type)
40 ->setNewValue(
41 array(
42 '-' => array_fuse($value),
43 ));
45 return array($xaction);
48 protected function newDropEffects($value) {
49 return array(
50 $this->newEffect()
51 ->setIcon('fa-briefcase', 'red')
52 ->setContent($this->getRuleViewDescription($value)),
56 protected function getDefaultValue() {
57 return null;
60 protected function getPHUIXControlType() {
61 return 'tokenizer';
64 private function getDatasource() {
65 return id(new PhabricatorProjectDatasource())
66 ->setViewer($this->getViewer());
69 protected function getPHUIXControlSpecification() {
70 $template = id(new AphrontTokenizerTemplateView())
71 ->setViewer($this->getViewer());
73 $template_markup = $template->render();
74 $datasource = $this->getDatasource();
76 return array(
77 'markup' => (string)hsprintf('%s', $template_markup),
78 'config' => array(
79 'src' => $datasource->getDatasourceURI(),
80 'browseURI' => $datasource->getBrowseURI(),
81 'placeholder' => $datasource->getPlaceholderText(),
82 'limit' => $datasource->getLimit(),
84 'value' => null,
88 public function getRuleViewLabel() {
89 return pht('Remove Project Tags');
92 public function getRuleViewDescription($value) {
93 return pht(
94 'Remove project tags: %s.',
95 phutil_tag(
96 'strong',
97 array(),
98 $this->getViewer()
99 ->renderHandleList($value)
100 ->setAsInline(true)
101 ->render()));
104 public function getRuleViewIcon($value) {
105 return id(new PHUIIconView())
106 ->setIcon('fa-briefcase', 'red');