Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14006245
D12503.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12503.diff
View Options
diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -243,6 +243,22 @@
return $this->queuedTransactions;
}
+ protected function newTransaction() {
+ $object = $this->getObject();
+
+ if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
+ throw new Exception(
+ pht(
+ 'Unable to build a new transaction for adapter object; it does '.
+ 'not implement "%s".',
+ 'PhabricatorApplicationTransactionInterface'));
+ }
+
+ return $object->getApplicationTransactionTemplate();
+ }
+
+
+
/**
* NOTE: You generally should not override this; it exists to support legacy
@@ -1482,7 +1498,21 @@
protected function applyStandardEffect(HeraldEffect $effect) {
$action = $effect->getAction();
+ $rule_type = $effect->getRule()->getRuleType();
+ $supported = $this->getActions($rule_type);
+ $supported = array_fuse($supported);
+ if (empty($supported[$action])) {
+ throw new Exception(
+ pht(
+ 'Adapter "%s" does not support action "%s" for rule type "%s".',
+ get_class($this),
+ $action,
+ $rule_type));
+ }
+
switch ($action) {
+ case self::ACTION_ADD_PROJECTS:
+ return $this->applyProjectsEffect($effect);
case self::ACTION_FLAG:
return $this->applyFlagEffect($effect);
case self::ACTION_EMAIL:
@@ -1507,6 +1537,32 @@
/**
* @task apply
*/
+ private function applyProjectsEffect(HeraldEffect $effect) {
+
+ $kind = '+';
+
+ $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
+ $project_phids = $effect->getTarget();
+ $xaction = $this->newTransaction()
+ ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
+ ->setMetadataValue('edge:type', $project_type)
+ ->setNewValue(
+ array(
+ $kind => array_fuse($project_phids),
+ ));
+
+ $this->queueTransaction($xaction);
+
+ return new HeraldApplyTranscript(
+ $effect,
+ true,
+ pht('Added projects.'));
+ }
+
+
+ /**
+ * @task apply
+ */
private function applyFlagEffect(HeraldEffect $effect) {
$phid = $this->getPHID();
$color = $effect->getTarget();
diff --git a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
--- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
+++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
@@ -5,7 +5,6 @@
private $task;
private $ccPHIDs = array();
private $assignPHID;
- private $projectPHIDs = array();
public function getAdapterApplicationClass() {
return 'PhabricatorManiphestApplication';
@@ -61,14 +60,6 @@
return $this->assignPHID;
}
- public function setProjectPHIDs(array $project_phids) {
- $this->projectPHIDs = $project_phids;
- return $this;
- }
- public function getProjectPHIDs() {
- return $this->projectPHIDs;
- }
-
public function getAdapterContentName() {
return pht('Maniphest Tasks');
}
@@ -181,15 +172,6 @@
true,
pht('Assigned task.'));
break;
- case self::ACTION_ADD_PROJECTS:
- foreach ($effect->getTarget() as $phid) {
- $this->projectPHIDs[] = $phid;
- }
- $result[] = new HeraldApplyTranscript(
- $effect,
- true,
- pht('Added projects.'));
- break;
default:
$result[] = $this->applyStandardEffect($effect);
break;
diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
--- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php
+++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
@@ -525,18 +525,6 @@
->setNewValue($assign_phid);
}
- $project_phids = $adapter->getProjectPHIDs();
- if ($project_phids) {
- $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
- $xactions[] = id(new ManiphestTransaction())
- ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
- ->setMetadataValue('edge:type', $project_type)
- ->setNewValue(
- array(
- '+' => array_fuse($project_phids),
- ));
- }
-
return $xactions;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 29, 4:02 AM (2 w, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711637
Default Alt Text
D12503.diff (4 KB)
Attached To
Mode
D12503: Make adding projects a standard Herald effect
Attached
Detach File
Event Timeline
Log In to Comment