Page MenuHomePhabricator

D12504.id30039.diff
No OneTemporary

D12504.id30039.diff

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
@@ -244,7 +244,7 @@
}
protected function newTransaction() {
- $object = $this->getObject();
+ $object = $this->newObject();
if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
throw new Exception(
@@ -258,8 +258,6 @@
}
-
-
/**
* NOTE: You generally should not override this; it exists to support legacy
* adapters which had hard-coded content types.
@@ -273,6 +271,26 @@
abstract public function getAdapterApplicationClass();
abstract public function getObject();
+
+ /**
+ * Return a new characteristic object for this adapter.
+ *
+ * The adapter will use this object to test for interfaces, generate
+ * transactions, and interact with custom fields.
+ *
+ * Adapters must return an object from this method to enable custom
+ * field rules and various implicit actions.
+ *
+ * Normally, you'll return an empty version of the adapted object:
+ *
+ * return new ApplicationObject();
+ *
+ * @return null|object Template object.
+ */
+ protected function newObject() {
+ return null;
+ }
+
public function supportsRuleType($rule_type) {
return false;
}
@@ -771,7 +789,19 @@
public function getActions($rule_type) {
$custom_actions = $this->getCustomActionsForRuleType($rule_type);
- return mpull($custom_actions, 'getActionKey');
+ $custom_actions = mpull($custom_actions, 'getActionKey');
+
+ $actions = $custom_actions;
+
+ $object = $this->newObject();
+
+ if (($object instanceof PhabricatorProjectInterface)) {
+ if ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL) {
+ $actions[] = self::ACTION_ADD_PROJECTS;
+ }
+ }
+
+ return $actions;
}
public function getActionNameMap($rule_type) {
@@ -1292,27 +1322,6 @@
/**
- * Return an object which custom fields can be generated from while editing
- * rules. Adapters must return an object from this method to enable custom
- * field rules.
- *
- * Normally, you'll return an empty version of the adapted object, assuming
- * it implements @{interface:PhabricatorCustomFieldInterface}:
- *
- * return new ApplicationObject();
- *
- * This is normally the only adapter method you need to override to enable
- * Herald rules to run against custom fields.
- *
- * @return null|PhabricatorCustomFieldInterface Template object.
- * @task customfield
- */
- protected function getCustomFieldTemplateObject() {
- return null;
- }
-
-
- /**
* Returns the prefix used to namespace Herald fields which are based on
* custom fields.
*
@@ -1363,8 +1372,8 @@
$this->customFields = null;
- $template_object = $this->getCustomFieldTemplateObject();
- if ($template_object) {
+ $template_object = $this->newObject();
+ if ($template_object instanceof PhabricatorCustomFieldInterface) {
$object = $this->getObject();
if (!$object) {
$object = $template_object;
diff --git a/src/applications/herald/adapter/HeraldCommitAdapter.php b/src/applications/herald/adapter/HeraldCommitAdapter.php
--- a/src/applications/herald/adapter/HeraldCommitAdapter.php
+++ b/src/applications/herald/adapter/HeraldCommitAdapter.php
@@ -26,6 +26,10 @@
return 'PhabricatorDiffusionApplication';
}
+ public function newObject() {
+ return new PhabricatorRepositoryCommit();
+ }
+
public function getObject() {
return $this->commit;
}
diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
--- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
+++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
@@ -24,6 +24,10 @@
return 'PhabricatorDifferentialApplication';
}
+ public function newObject() {
+ return new DifferentialRevision();
+ }
+
public function getObject() {
return $this->revision;
}
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
@@ -6,6 +6,10 @@
private $ccPHIDs = array();
private $assignPHID;
+ protected function newObject() {
+ return new ManiphestTask();
+ }
+
public function getAdapterApplicationClass() {
return 'PhabricatorManiphestApplication';
}
@@ -90,7 +94,6 @@
self::ACTION_ADD_CC,
self::ACTION_EMAIL,
self::ACTION_ASSIGN_TASK,
- self::ACTION_ADD_PROJECTS,
self::ACTION_NOTHING,
),
parent::getActions($rule_type));
@@ -180,8 +183,4 @@
return $result;
}
- protected function getCustomFieldTemplateObject() {
- return new ManiphestTask();
- }
-
}
diff --git a/src/applications/herald/adapter/HeraldPholioMockAdapter.php b/src/applications/herald/adapter/HeraldPholioMockAdapter.php
--- a/src/applications/herald/adapter/HeraldPholioMockAdapter.php
+++ b/src/applications/herald/adapter/HeraldPholioMockAdapter.php
@@ -13,6 +13,10 @@
return pht('React to mocks being created or updated.');
}
+ public function newObject() {
+ return new PholioMock();
+ }
+
public function getObject() {
return $this->mock;
}
diff --git a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php
--- a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php
+++ b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php
@@ -13,6 +13,10 @@
return pht('React to wiki documents being created or updated.');
}
+ public function newObject() {
+ return new PhrictionDocument();
+ }
+
public function getObject() {
return $this->document;
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 9:49 AM (2 w, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705238
Default Alt Text
D12504.id30039.diff (6 KB)

Event Timeline