Page MenuHomePhabricator

D20379.diff
No OneTemporary

D20379.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4208,6 +4208,7 @@
'PhabricatorProjectTransactionQuery' => 'applications/project/query/PhabricatorProjectTransactionQuery.php',
'PhabricatorProjectTransactionType' => 'applications/project/xaction/PhabricatorProjectTransactionType.php',
'PhabricatorProjectTrigger' => 'applications/project/storage/PhabricatorProjectTrigger.php',
+ 'PhabricatorProjectTriggerAddProjectsRule' => 'applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php',
'PhabricatorProjectTriggerController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerController.php',
'PhabricatorProjectTriggerCorruptionException' => 'applications/project/exception/PhabricatorProjectTriggerCorruptionException.php',
'PhabricatorProjectTriggerEditController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerEditController.php',
@@ -10383,6 +10384,7 @@
'PhabricatorIndexableInterface',
'PhabricatorDestructibleInterface',
),
+ 'PhabricatorProjectTriggerAddProjectsRule' => 'PhabricatorProjectTriggerRule',
'PhabricatorProjectTriggerController' => 'PhabricatorProjectController',
'PhabricatorProjectTriggerCorruptionException' => 'Exception',
'PhabricatorProjectTriggerEditController' => 'PhabricatorProjectTriggerController',
diff --git a/src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php b/src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php
@@ -0,0 +1,103 @@
+<?php
+
+final class PhabricatorProjectTriggerAddProjectsRule
+ extends PhabricatorProjectTriggerRule {
+
+ const TRIGGERTYPE = 'task.projects.add';
+
+ public function getSelectControLname() {
+ return pht('Add projects');
+ }
+
+ protected function getValueForEditorField() {
+ return $this->getDatasource()->getWireTokens($this->getValue());
+ }
+
+ protected function assertValidRuleValue($value) {
+ if (!is_array($value)) {
+ throw new Exception(
+ pht(
+ 'Add 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')
+ ->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('Add Projects');
+ }
+
+ public function getRuleViewDescription($value) {
+ return pht(
+ 'Add projects: %s.',
+ phutil_tag(
+ 'strong',
+ array(),
+ $this->getViewer()
+ ->renderHandleList($value)
+ ->setAsInline(true)
+ ->render()));
+ }
+
+ public function getRuleViewIcon($value) {
+ return id(new PHUIIconView())
+ ->setIcon('fa-briefcase', 'green');
+ }
+
+
+
+}
diff --git a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php
--- a/src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php
+++ b/src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php
@@ -66,7 +66,7 @@
return 'tokenizer';
}
- protected function getDatasource() {
+ private function getDatasource() {
$datasource = id(new ManiphestAssigneeDatasource())
->setLimit(1);

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 4:49 AM (12 h, 27 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920652
Default Alt Text
D20379.diff (4 KB)

Event Timeline