Differential D20390 Diff 48662 src/applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php
- This file was added.
| <?php | |||||
| final class PhabricatorProjectTriggerRemoveProjectsRule | |||||
| extends PhabricatorProjectTriggerRule { | |||||
| const TRIGGERTYPE = 'task.projects.remove'; | |||||
| public function getSelectControLname() { | |||||
| return pht('Remove projects'); | |||||
| } | |||||
| protected function getValueForEditorField() { | |||||
| return $this->getDatasource()->getWireTokens($this->getValue()); | |||||
| } | |||||
| protected function assertValidRuleValue($value) { | |||||
| if (!is_array($value)) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Remove project rule value should be a list, but is not '. | |||||
| '(value is "%s").', | |||||
| phutil_describe_type($value))); | |||||
| } | |||||
| } | |||||
| protected function newDropTransactions($object, $value) { | |||||
| $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | |||||
| $xaction = $object->getApplicationTransactionTemplate() | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | |||||
| ->setMetadataValue('edge:type', $project_edge_type) | |||||
| ->setNewValue( | |||||
| array( | |||||
| '-' => array_fuse($value), | |||||
| )); | |||||
| return array($xaction); | |||||
| } | |||||
| protected function newDropEffects($value) { | |||||
| return array( | |||||
| $this->newEffect() | |||||
| ->setIcon('fa-briefcase', 'red') | |||||
| ->setContent($this->getRuleViewDescription($value)), | |||||
| ); | |||||
| } | |||||
| protected function getDefaultValue() { | |||||
| return null; | |||||
| } | |||||
| protected function getPHUIXControlType() { | |||||
| return 'tokenizer'; | |||||
| } | |||||
| private function getDatasource() { | |||||
| return id(new PhabricatorProjectDatasource()) | |||||
| ->setViewer($this->getViewer()); | |||||
| } | |||||
| protected function getPHUIXControlSpecification() { | |||||
| $template = id(new AphrontTokenizerTemplateView()) | |||||
| ->setViewer($this->getViewer()); | |||||
| $template_markup = $template->render(); | |||||
| $datasource = $this->getDatasource(); | |||||
| return array( | |||||
| 'markup' => (string)hsprintf('%s', $template_markup), | |||||
| 'config' => array( | |||||
| 'src' => $datasource->getDatasourceURI(), | |||||
| 'browseURI' => $datasource->getBrowseURI(), | |||||
| 'placeholder' => $datasource->getPlaceholderText(), | |||||
| 'limit' => $datasource->getLimit(), | |||||
| ), | |||||
| 'value' => null, | |||||
| ); | |||||
| } | |||||
| public function getRuleViewLabel() { | |||||
| return pht('Remove Projects'); | |||||
| } | |||||
| public function getRuleViewDescription($value) { | |||||
| return pht( | |||||
| 'Remove projects: %s.', | |||||
| phutil_tag( | |||||
| 'strong', | |||||
| array(), | |||||
| $this->getViewer() | |||||
| ->renderHandleList($value) | |||||
| ->setAsInline(true) | |||||
| ->render())); | |||||
| } | |||||
| public function getRuleViewIcon($value) { | |||||
| return id(new PHUIIconView()) | |||||
| ->setIcon('fa-briefcase', 'red'); | |||||
| } | |||||
| } | |||||