Page MenuHomePhabricator

D13495.diff
No OneTemporary

D13495.diff

diff --git a/resources/sql/autopatches/20140210.herald.rule-condition-mig.php b/resources/sql/autopatches/20140210.herald.rule-condition-mig.php
--- a/resources/sql/autopatches/20140210.herald.rule-condition-mig.php
+++ b/resources/sql/autopatches/20140210.herald.rule-condition-mig.php
@@ -6,7 +6,7 @@
echo pht(
"Migrating Herald conditions of type Herald rule from IDs to PHIDs...\n");
foreach (new LiskMigrationIterator($table) as $condition) {
- if ($condition->getFieldName() != HeraldAdapter::FIELD_RULE) {
+ if ($condition->getFieldName() != HeraldAnotherRuleField::FIELDCONST) {
continue;
}
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
@@ -930,6 +930,8 @@
'HarbormasterWorker' => 'applications/harbormaster/worker/HarbormasterWorker.php',
'HeraldAction' => 'applications/herald/storage/HeraldAction.php',
'HeraldAdapter' => 'applications/herald/adapter/HeraldAdapter.php',
+ 'HeraldAlwaysField' => 'applications/herald/field/HeraldAlwaysField.php',
+ 'HeraldAnotherRuleField' => 'applications/herald/field/HeraldAnotherRuleField.php',
'HeraldApplyTranscript' => 'applications/herald/storage/transcript/HeraldApplyTranscript.php',
'HeraldCommitAdapter' => 'applications/herald/adapter/HeraldCommitAdapter.php',
'HeraldCondition' => 'applications/herald/storage/HeraldCondition.php',
@@ -950,11 +952,13 @@
'HeraldManageGlobalRulesCapability' => 'applications/herald/capability/HeraldManageGlobalRulesCapability.php',
'HeraldManiphestTaskAdapter' => 'applications/herald/adapter/HeraldManiphestTaskAdapter.php',
'HeraldNewController' => 'applications/herald/controller/HeraldNewController.php',
+ 'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php',
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php',
'HeraldPholioMockAdapter' => 'applications/herald/adapter/HeraldPholioMockAdapter.php',
'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php',
'HeraldPreCommitContentAdapter' => 'applications/diffusion/herald/HeraldPreCommitContentAdapter.php',
'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php',
+ 'HeraldProjectsField' => 'applications/project/herald/HeraldProjectsField.php',
'HeraldRecursiveConditionsException' => 'applications/herald/engine/exception/HeraldRecursiveConditionsException.php',
'HeraldRemarkupRule' => 'applications/herald/remarkup/HeraldRemarkupRule.php',
'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php',
@@ -972,6 +976,8 @@
'HeraldRuleTypeConfig' => 'applications/herald/config/HeraldRuleTypeConfig.php',
'HeraldRuleViewController' => 'applications/herald/controller/HeraldRuleViewController.php',
'HeraldSchemaSpec' => 'applications/herald/storage/HeraldSchemaSpec.php',
+ 'HeraldSpaceField' => 'applications/spaces/herald/HeraldSpaceField.php',
+ 'HeraldSubscribersField' => 'applications/subscriptions/herald/HeraldSubscribersField.php',
'HeraldTestConsoleController' => 'applications/herald/controller/HeraldTestConsoleController.php',
'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php',
'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php',
@@ -4427,6 +4433,8 @@
'HarbormasterWorker' => 'PhabricatorWorker',
'HeraldAction' => 'HeraldDAO',
'HeraldAdapter' => 'Phobject',
+ 'HeraldAlwaysField' => 'HeraldField',
+ 'HeraldAnotherRuleField' => 'HeraldField',
'HeraldApplyTranscript' => 'Phobject',
'HeraldCommitAdapter' => 'HeraldAdapter',
'HeraldCondition' => 'HeraldDAO',
@@ -4447,11 +4455,13 @@
'HeraldManageGlobalRulesCapability' => 'PhabricatorPolicyCapability',
'HeraldManiphestTaskAdapter' => 'HeraldAdapter',
'HeraldNewController' => 'HeraldController',
+ 'HeraldNewObjectField' => 'HeraldField',
'HeraldObjectTranscript' => 'Phobject',
'HeraldPholioMockAdapter' => 'HeraldAdapter',
'HeraldPreCommitAdapter' => 'HeraldAdapter',
'HeraldPreCommitContentAdapter' => 'HeraldPreCommitAdapter',
'HeraldPreCommitRefAdapter' => 'HeraldPreCommitAdapter',
+ 'HeraldProjectsField' => 'HeraldField',
'HeraldRecursiveConditionsException' => 'Exception',
'HeraldRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'HeraldRepetitionPolicyConfig' => 'Phobject',
@@ -4475,6 +4485,8 @@
'HeraldRuleTypeConfig' => 'Phobject',
'HeraldRuleViewController' => 'HeraldController',
'HeraldSchemaSpec' => 'PhabricatorConfigSchemaSpec',
+ 'HeraldSpaceField' => 'HeraldField',
+ 'HeraldSubscribersField' => 'HeraldField',
'HeraldTestConsoleController' => 'HeraldController',
'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'HeraldTranscript' => array(
diff --git a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php
--- a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php
+++ b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php
@@ -23,6 +23,14 @@
return 'PhabricatorDiffusionApplication';
}
+ protected function initializeNewAdapter() {
+ $this->log = new PhabricatorRepositoryPushLog();
+ }
+
+ public function isSingleEventAdapter() {
+ return true;
+ }
+
public function getObject() {
return $this->log;
}
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
@@ -12,7 +12,6 @@
const FIELD_REVIEWER = 'reviewer';
const FIELD_REVIEWERS = 'reviewers';
const FIELD_COMMITTER = 'committer';
- const FIELD_CC = 'cc';
const FIELD_TAGS = 'tags';
const FIELD_DIFF_FILE = 'diff-file';
const FIELD_DIFF_CONTENT = 'diff-content';
@@ -21,12 +20,9 @@
const FIELD_DIFF_ENORMOUS = 'diff-enormous';
const FIELD_REPOSITORY = 'repository';
const FIELD_REPOSITORY_PROJECTS = 'repository-projects';
- const FIELD_RULE = 'rule';
const FIELD_AFFECTED_PACKAGE = 'affected-package';
const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner';
- const FIELD_ALWAYS = 'always';
const FIELD_AUTHOR_PROJECTS = 'authorprojects';
- const FIELD_PROJECTS = 'projects';
const FIELD_PUSHER = 'pusher';
const FIELD_PUSHER_PROJECTS = 'pusher-projects';
const FIELD_DIFFERENTIAL_REVISION = 'differential-revision';
@@ -37,13 +33,11 @@
const FIELD_BRANCHES = 'branches';
const FIELD_AUTHOR_RAW = 'author-raw';
const FIELD_COMMITTER_RAW = 'committer-raw';
- const FIELD_IS_NEW_OBJECT = 'new-object';
const FIELD_APPLICATION_EMAIL = 'applicaton-email';
const FIELD_TASK_PRIORITY = 'taskpriority';
const FIELD_TASK_STATUS = 'taskstatus';
const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer';
const FIELD_PATH = 'path';
- const FIELD_SPACE = 'space';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@@ -196,26 +190,6 @@
}
switch ($field_name) {
- case self::FIELD_RULE:
- return null;
- case self::FIELD_ALWAYS:
- return true;
- case self::FIELD_IS_NEW_OBJECT:
- return $this->getIsNewObject();
- case self::FIELD_CC:
- $object = $this->getObject();
-
- if (!($object instanceof PhabricatorSubscribableInterface)) {
- throw new Exception(
- pht(
- 'Adapter object (of class "%s") does not implement interface '.
- '"%s", so the subscribers field value can not be determined.',
- get_class($object),
- 'PhabricatorSubscribableInterface'));
- }
-
- $phid = $object->getPHID();
- return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
case self::FIELD_APPLICATION_EMAIL:
$value = array();
// while there is only one match by implementation, we do set
@@ -224,19 +198,6 @@
$value[] = $this->getApplicationEmail()->getPHID();
}
return $value;
- case self::FIELD_SPACE:
- $object = $this->getObject();
-
- if (!($object instanceof PhabricatorSpacesInterface)) {
- throw new Exception(
- pht(
- 'Adapter object (of class "%s") does not implement interface '.
- '"%s", so the Space field value can not be determined.',
- get_class($object),
- 'PhabricatorSpacesInterface'));
- }
-
- return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
default:
if ($this->isHeraldCustomKey($field_name)) {
return $this->getCustomFieldValue($field_name);
@@ -367,6 +328,8 @@
$map = array();
$all = HeraldField::getAllFields();
foreach ($all as $key => $field) {
+ $field = id(clone $field)->setAdapter($this);
+
if (!$field->supportsObject($object)) {
continue;
}
@@ -404,9 +367,6 @@
public function getFields() {
$fields = array_keys($this->getFieldImplementationMap());
- $fields[] = self::FIELD_ALWAYS;
- $fields[] = self::FIELD_RULE;
-
$custom_fields = $this->getCustomFields();
if ($custom_fields) {
foreach ($custom_fields->getFields() as $custom_field) {
@@ -429,7 +389,6 @@
self::FIELD_COMMITTER => pht('Committer'),
self::FIELD_REVIEWER => pht('Reviewer'),
self::FIELD_REVIEWERS => pht('Reviewers'),
- self::FIELD_CC => pht('CCs'),
self::FIELD_TAGS => pht('Tags'),
self::FIELD_DIFF_FILE => pht('Any changed filename'),
self::FIELD_DIFF_CONTENT => pht('Any changed file content'),
@@ -438,13 +397,10 @@
self::FIELD_DIFF_ENORMOUS => pht('Change is enormous'),
self::FIELD_REPOSITORY => pht('Repository'),
self::FIELD_REPOSITORY_PROJECTS => pht('Repository\'s projects'),
- self::FIELD_RULE => pht('Another Herald rule'),
self::FIELD_AFFECTED_PACKAGE => pht('Any affected package'),
self::FIELD_AFFECTED_PACKAGE_OWNER =>
pht("Any affected package's owner"),
- self::FIELD_ALWAYS => pht('Always'),
self::FIELD_AUTHOR_PROJECTS => pht("Author's projects"),
- self::FIELD_PROJECTS => pht('Projects'),
self::FIELD_PUSHER => pht('Pusher'),
self::FIELD_PUSHER_PROJECTS => pht("Pusher's projects"),
self::FIELD_DIFFERENTIAL_REVISION => pht('Differential revision'),
@@ -456,13 +412,11 @@
self::FIELD_BRANCHES => pht('Commit\'s branches'),
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
- self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
self::FIELD_APPLICATION_EMAIL => pht('Receiving email address'),
self::FIELD_TASK_PRIORITY => pht('Task priority'),
self::FIELD_TASK_STATUS => pht('Task status'),
self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'),
self::FIELD_PATH => pht('Path'),
- self::FIELD_SPACE => pht('Space'),
) + $this->getCustomFieldNameMap();
}
@@ -521,7 +475,6 @@
case self::FIELD_PUSHER:
case self::FIELD_TASK_PRIORITY:
case self::FIELD_TASK_STATUS:
- case self::FIELD_SPACE:
return array(
self::CONDITION_IS_ANY,
self::CONDITION_IS_NOT_ANY,
@@ -538,9 +491,7 @@
);
case self::FIELD_TAGS:
case self::FIELD_REVIEWERS:
- case self::FIELD_CC:
case self::FIELD_AUTHOR_PROJECTS:
- case self::FIELD_PROJECTS:
case self::FIELD_AFFECTED_PACKAGE:
case self::FIELD_AFFECTED_PACKAGE_OWNER:
case self::FIELD_PUSHER_PROJECTS:
@@ -573,15 +524,6 @@
self::CONDITION_REGEXP,
self::CONDITION_REGEXP_PAIR,
);
- case self::FIELD_RULE:
- return array(
- self::CONDITION_RULE,
- self::CONDITION_NOT_RULE,
- );
- case self::FIELD_ALWAYS:
- return array(
- self::CONDITION_UNCONDITIONALLY,
- );
case self::FIELD_DIFFERENTIAL_REVIEWERS:
return array(
self::CONDITION_EXISTS,
@@ -604,7 +546,6 @@
);
case self::FIELD_IS_MERGE_COMMIT:
case self::FIELD_DIFF_ENORMOUS:
- case self::FIELD_IS_NEW_OBJECT:
case self::FIELD_PUSHER_IS_COMMITTER:
return array(
self::CONDITION_IS_TRUE,
@@ -1019,8 +960,6 @@
return self::VALUE_TASK_PRIORITY;
case self::FIELD_TASK_STATUS:
return self::VALUE_TASK_STATUS;
- case self::FIELD_SPACE:
- return self::VALUE_SPACE;
default:
return self::VALUE_USER;
}
@@ -1031,15 +970,12 @@
switch ($field) {
case self::FIELD_REPOSITORY:
return self::VALUE_REPOSITORY;
- case self::FIELD_CC:
- return self::VALUE_EMAIL;
case self::FIELD_TAGS:
return self::VALUE_TAG;
case self::FIELD_AFFECTED_PACKAGE:
return self::VALUE_OWNERS_PACKAGE;
case self::FIELD_AUTHOR_PROJECTS:
case self::FIELD_PUSHER_PROJECTS:
- case self::FIELD_PROJECTS:
case self::FIELD_REPOSITORY_PROJECTS:
return self::VALUE_PROJECT;
case self::FIELD_REVIEWERS:
@@ -1059,9 +995,6 @@
case self::CONDITION_IS_TRUE:
case self::CONDITION_IS_FALSE:
return self::VALUE_NONE;
- case self::CONDITION_RULE:
- case self::CONDITION_NOT_RULE:
- return self::VALUE_RULE;
default:
throw new Exception(pht("Unknown condition '%s'.", $condition));
}
@@ -1133,6 +1066,20 @@
);
}
+ abstract protected function initializeNewAdapter();
+
+ /**
+ * Does this adapter's event fire only once?
+ *
+ * Single use adapters (like pre-commit and diff adapters) only fire once,
+ * so fields like "Is new object" don't make sense to apply to their content.
+ *
+ * @return bool
+ */
+ public function isSingleEventAdapter() {
+ return false;
+ }
+
public static function getAllAdapters() {
static $adapters;
if (!$adapters) {
@@ -1149,6 +1096,8 @@
foreach ($adapters as $adapter) {
if ($adapter->getAdapterContentType() == $content_type) {
+ $adapter = id(clone $adapter);
+ $adapter->initializeNewAdapter();
return $adapter;
}
}
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
@@ -29,6 +29,10 @@
return new PhabricatorRepositoryCommit();
}
+ protected function initializeNewAdapter() {
+ $this->commit = $this->newObject();
+ }
+
public function getObject() {
return $this->commit;
}
diff --git a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php b/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
--- a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
+++ b/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
@@ -6,6 +6,14 @@
return 'PhabricatorDifferentialApplication';
}
+ protected function initializeNewAdapter() {
+ $this->setDiff(new DifferentialDiff());
+ }
+
+ public function isSingleEventAdapter() {
+ return true;
+ }
+
protected function loadChangesets() {
return $this->loadChangesetsWithHunks();
}
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 new DifferentialRevision();
}
+ protected function initializeNewAdapter() {
+ $this->revision = $this->newObject();
+ }
+
public function getObject() {
return $this->revision;
}
@@ -66,7 +70,6 @@
self::FIELD_AUTHOR,
self::FIELD_AUTHOR_PROJECTS,
self::FIELD_REVIEWERS,
- self::FIELD_CC,
self::FIELD_REPOSITORY,
self::FIELD_REPOSITORY_PROJECTS,
self::FIELD_DIFF_FILE,
@@ -75,7 +78,6 @@
self::FIELD_DIFF_REMOVED_CONTENT,
self::FIELD_AFFECTED_PACKAGE,
self::FIELD_AFFECTED_PACKAGE_OWNER,
- self::FIELD_IS_NEW_OBJECT,
),
parent::getFields());
}
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
@@ -17,6 +17,10 @@
return pht('React to tasks being created or updated.');
}
+ protected function initializeNewAdapter() {
+ $this->task = $this->newObject();
+ }
+
public function getRepetitionOptions() {
return array(
HeraldRepetitionPolicyConfig::EVERY,
@@ -66,13 +70,9 @@
self::FIELD_BODY,
self::FIELD_AUTHOR,
self::FIELD_ASSIGNEE,
- self::FIELD_CC,
- self::FIELD_PROJECTS,
self::FIELD_TASK_PRIORITY,
self::FIELD_TASK_STATUS,
- self::FIELD_IS_NEW_OBJECT,
self::FIELD_APPLICATION_EMAIL,
- self::FIELD_SPACE,
),
parent::getFields());
}
@@ -121,10 +121,6 @@
return $this->getTask()->getAuthorPHID();
case self::FIELD_ASSIGNEE:
return $this->getTask()->getOwnerPHID();
- case self::FIELD_PROJECTS:
- return PhabricatorEdgeQuery::loadDestinationPHIDs(
- $this->getTask()->getPHID(),
- PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
case self::FIELD_TASK_PRIORITY:
return $this->getTask()->getPriority();
case self::FIELD_TASK_STATUS:
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
@@ -12,6 +12,10 @@
return pht('React to mocks being created or updated.');
}
+ protected function initializeNewAdapter() {
+ $this->mock = $this->newObject();
+ }
+
protected function newObject() {
return new PholioMock();
}
@@ -49,10 +53,6 @@
self::FIELD_TITLE,
self::FIELD_BODY,
self::FIELD_AUTHOR,
- self::FIELD_CC,
- self::FIELD_PROJECTS,
- self::FIELD_IS_NEW_OBJECT,
- self::FIELD_SPACE,
),
parent::getFields());
}
@@ -95,10 +95,6 @@
return $this->getMock()->getDescription();
case self::FIELD_AUTHOR:
return $this->getMock()->getAuthorPHID();
- case self::FIELD_PROJECTS:
- return PhabricatorEdgeQuery::loadDestinationPHIDs(
- $this->getMock()->getPHID(),
- PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
return parent::getHeraldField($field);
diff --git a/src/applications/herald/controller/HeraldTranscriptController.php b/src/applications/herald/controller/HeraldTranscriptController.php
--- a/src/applications/herald/controller/HeraldTranscriptController.php
+++ b/src/applications/herald/controller/HeraldTranscriptController.php
@@ -117,7 +117,7 @@
protected function renderConditionTestValue($condition, $handles) {
switch ($condition->getFieldName()) {
- case HeraldAdapter::FIELD_RULE:
+ case HeraldAnotherRuleField::FIELDCONST:
$value = array($condition->getTestValue());
break;
default:
@@ -204,7 +204,7 @@
}
foreach ($condition_xscripts as $condition_xscript) {
switch ($condition_xscript->getFieldName()) {
- case HeraldAdapter::FIELD_RULE:
+ case HeraldAnotherRuleField::FIELDCONST:
$phids[] = $condition_xscript->getTestValue();
break;
default:
diff --git a/src/applications/herald/field/HeraldAlwaysField.php b/src/applications/herald/field/HeraldAlwaysField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/HeraldAlwaysField.php
@@ -0,0 +1,29 @@
+<?php
+
+final class HeraldAlwaysField extends HeraldField {
+
+ const FIELDCONST = 'always';
+
+ public function getHeraldFieldName() {
+ return pht('Always');
+ }
+
+ public function getHeraldFieldValue($object) {
+ return true;
+ }
+
+ public function getHeraldFieldConditions() {
+ return array(
+ HeraldAdapter::CONDITION_UNCONDITIONALLY,
+ );
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ return HeraldAdapter::VALUE_NONE;
+ }
+
+ public function supportsObject($object) {
+ return true;
+ }
+
+}
diff --git a/src/applications/herald/field/HeraldAnotherRuleField.php b/src/applications/herald/field/HeraldAnotherRuleField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/HeraldAnotherRuleField.php
@@ -0,0 +1,31 @@
+<?php
+
+final class HeraldAnotherRuleField extends HeraldField {
+
+ const FIELDCONST = 'rule';
+
+ public function getHeraldFieldName() {
+ return pht('Another Herald rule');
+ }
+
+ public function supportsObject($object) {
+ return true;
+ }
+
+ public function getHeraldFieldValue($object) {
+ return null;
+ }
+
+ public function getHeraldFieldConditions() {
+ return array(
+ HeraldAdapter::CONDITION_RULE,
+ HeraldAdapter::CONDITION_NOT_RULE,
+ );
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ return HeraldAdapter::VALUE_RULE;
+ }
+
+
+}
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -4,9 +4,43 @@
private $adapter;
+ const STANDARD_LIST = 'standard.list';
+ const STANDARD_BOOL = 'standard.bool';
+ const STANDARD_PHID = 'standard.phid';
+
abstract public function getHeraldFieldName();
abstract public function getHeraldFieldValue($object);
- abstract public function getHeraldFieldConditions();
+
+ public function getHeraldFieldConditions() {
+ switch ($this->getHeraldFieldStandardConditions()) {
+ case self::STANDARD_LIST:
+ return array(
+ HeraldAdapter::CONDITION_INCLUDE_ALL,
+ HeraldAdapter::CONDITION_INCLUDE_ANY,
+ HeraldAdapter::CONDITION_INCLUDE_NONE,
+ HeraldAdapter::CONDITION_EXISTS,
+ HeraldAdapter::CONDITION_NOT_EXISTS,
+ );
+ case self::STANDARD_BOOL:
+ return array(
+ HeraldAdapter::CONDITION_IS_TRUE,
+ HeraldAdapter::CONDITION_IS_FALSE,
+ );
+ case self::STANDARD_PHID:
+ return array(
+ HeraldAdapter::CONDITION_IS_ANY,
+ HeraldAdapter::CONDITION_IS_NOT_ANY,
+ );
+
+ }
+
+ throw new Exception(pht('Unknown standard condition set.'));
+ }
+
+ protected function getHeraldFieldStandardConditions() {
+ throw new PhutilMethodNotImplementedException();
+ }
+
abstract public function getHeraldFieldValueType($condition);
abstract public function supportsObject($object);
diff --git a/src/applications/herald/field/HeraldNewObjectField.php b/src/applications/herald/field/HeraldNewObjectField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/field/HeraldNewObjectField.php
@@ -0,0 +1,27 @@
+<?php
+
+final class HeraldNewObjectField extends HeraldField {
+
+ const FIELDCONST = 'new-object';
+
+ public function getHeraldFieldName() {
+ return pht('Is newly created');
+ }
+
+ public function supportsObject($object) {
+ return !$this->getAdapter()->isSingleEventAdapter();
+ }
+
+ public function getHeraldFieldValue($object) {
+ return $this->getAdapter()->getIsNewObject();
+ }
+
+ protected function getHeraldFieldStandardConditions() {
+ return self::STANDARD_BOOL;
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ return HeraldAdapter::VALUE_NONE;
+ }
+
+}
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
@@ -12,6 +12,10 @@
return pht('React to wiki documents being created or updated.');
}
+ protected function initializeNewAdapter() {
+ $this->document = $this->newObject();
+ }
+
protected function newObject() {
return new PhrictionDocument();
}
@@ -50,8 +54,6 @@
self::FIELD_TITLE,
self::FIELD_BODY,
self::FIELD_AUTHOR,
- self::FIELD_IS_NEW_OBJECT,
- self::FIELD_CC,
self::FIELD_PATH,
),
parent::getFields());
diff --git a/src/applications/project/herald/HeraldProjectsField.php b/src/applications/project/herald/HeraldProjectsField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/herald/HeraldProjectsField.php
@@ -0,0 +1,35 @@
+<?php
+
+final class HeraldProjectsField extends HeraldField {
+
+ const FIELDCONST = 'projects';
+
+ public function getHeraldFieldName() {
+ return pht('Projects');
+ }
+
+ public function supportsObject($object) {
+ return ($object instanceof PhabricatorProjectInterface);
+ }
+
+ public function getHeraldFieldValue($object) {
+ return PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $object->getPHID(),
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
+ }
+
+ protected function getHeraldFieldStandardConditions() {
+ return self::STANDARD_LIST;
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ switch ($condition) {
+ case HeraldAdapter::CONDITION_EXISTS:
+ case HeraldAdapter::CONDITION_NOT_EXISTS:
+ return HeraldAdapter::VALUE_NONE;
+ default:
+ return HeraldAdapter::VALUE_PROJECT;
+ }
+ }
+
+}
diff --git a/src/applications/spaces/herald/HeraldSpaceField.php b/src/applications/spaces/herald/HeraldSpaceField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/spaces/herald/HeraldSpaceField.php
@@ -0,0 +1,27 @@
+<?php
+
+final class HeraldSpaceField extends HeraldField {
+
+ const FIELDCONST = 'space';
+
+ public function getHeraldFieldName() {
+ return pht('Space');
+ }
+
+ public function supportsObject($object) {
+ return ($object instanceof PhabricatorSpacesInterface);
+ }
+
+ public function getHeraldFieldValue($object) {
+ return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
+ }
+
+ protected function getHeraldFieldStandardConditions() {
+ return self::STANDARD_PHID;
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ return HeraldAdapter::VALUE_SPACE;
+ }
+
+}
diff --git a/src/applications/subscriptions/herald/HeraldSubscribersField.php b/src/applications/subscriptions/herald/HeraldSubscribersField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/subscriptions/herald/HeraldSubscribersField.php
@@ -0,0 +1,34 @@
+<?php
+
+final class HeraldSubscribersField extends HeraldField {
+
+ const FIELDCONST = 'cc';
+
+ public function getHeraldFieldName() {
+ return pht('Subscribers');
+ }
+
+ public function supportsObject($object) {
+ return ($object instanceof PhabricatorSubscribableInterface);
+ }
+
+ public function getHeraldFieldValue($object) {
+ $phid = $object->getPHID();
+ return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
+ }
+
+ protected function getHeraldFieldStandardConditions() {
+ return self::STANDARD_LIST;
+ }
+
+ public function getHeraldFieldValueType($condition) {
+ switch ($condition) {
+ case HeraldAdapter::CONDITION_EXISTS:
+ case HeraldAdapter::CONDITION_NOT_EXISTS:
+ return HeraldAdapter::VALUE_NONE;
+ default:
+ return HeraldAdapter::VALUE_PROJECT;
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
May 12 2024, 6:29 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6290745
Default Alt Text
D13495.diff (27 KB)

Event Timeline