diff --git a/resources/sql/autopatches/20140210.herald.rule-condition-mig.php b/resources/sql/autopatches/20140210.herald.rule-condition-mig.php index 90f8aa0b3e..9a5e40ba0c 100644 --- a/resources/sql/autopatches/20140210.herald.rule-condition-mig.php +++ b/resources/sql/autopatches/20140210.herald.rule-condition-mig.php @@ -6,7 +6,7 @@ $conn_w = $table->establishConnection('w'); 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 index 53c7797288..012d958cd9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -930,6 +930,8 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( 'HarbormasterWorker' => 'PhabricatorWorker', 'HeraldAction' => 'HeraldDAO', 'HeraldAdapter' => 'Phobject', + 'HeraldAlwaysField' => 'HeraldField', + 'HeraldAnotherRuleField' => 'HeraldField', 'HeraldApplyTranscript' => 'Phobject', 'HeraldCommitAdapter' => 'HeraldAdapter', 'HeraldCondition' => 'HeraldDAO', @@ -4447,11 +4455,13 @@ phutil_register_library_map(array( '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 @@ phutil_register_library_map(array( '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 index 8e8f89a88e..d7c967a93f 100644 --- a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php @@ -23,6 +23,14 @@ abstract class HeraldPreCommitAdapter extends HeraldAdapter { 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 index fcfaa052a0..62f9087c1d 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -12,7 +12,6 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { } 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 @@ abstract class HeraldAdapter extends Phobject { $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 @@ abstract class HeraldAdapter extends Phobject { $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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { ); 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { ); 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 @@ abstract class HeraldAdapter extends Phobject { 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 class HeraldAdapter extends Phobject { ); } + 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 @@ abstract class HeraldAdapter extends Phobject { 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 index b420ddb57a..765e152f1b 100644 --- a/src/applications/herald/adapter/HeraldCommitAdapter.php +++ b/src/applications/herald/adapter/HeraldCommitAdapter.php @@ -29,6 +29,10 @@ final class HeraldCommitAdapter extends HeraldAdapter { 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 index c4c6587167..ba7f826312 100644 --- a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php +++ b/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php @@ -6,6 +6,14 @@ final class HeraldDifferentialDiffAdapter extends HeraldDifferentialAdapter { 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 index a731254870..2c2e1f2e09 100644 --- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php +++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php @@ -24,6 +24,10 @@ final class HeraldDifferentialRevisionAdapter return new DifferentialRevision(); } + protected function initializeNewAdapter() { + $this->revision = $this->newObject(); + } + public function getObject() { return $this->revision; } @@ -66,7 +70,6 @@ final class HeraldDifferentialRevisionAdapter 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 @@ final class HeraldDifferentialRevisionAdapter 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 index 0116c61a24..451b84c6a2 100644 --- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php +++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php @@ -17,6 +17,10 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { 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 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { 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 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { 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 index 5c9c78c0ac..68ad31ecc8 100644 --- a/src/applications/herald/adapter/HeraldPholioMockAdapter.php +++ b/src/applications/herald/adapter/HeraldPholioMockAdapter.php @@ -12,6 +12,10 @@ final class HeraldPholioMockAdapter extends HeraldAdapter { 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 @@ final class HeraldPholioMockAdapter extends HeraldAdapter { 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 @@ final class HeraldPholioMockAdapter extends HeraldAdapter { 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 index a915e55b3d..359f0f39e6 100644 --- a/src/applications/herald/controller/HeraldTranscriptController.php +++ b/src/applications/herald/controller/HeraldTranscriptController.php @@ -117,7 +117,7 @@ final class HeraldTranscriptController extends HeraldController { 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 @@ final class HeraldTranscriptController extends HeraldController { } 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 index 0000000000..f52c9a0fc8 --- /dev/null +++ b/src/applications/herald/field/HeraldAlwaysField.php @@ -0,0 +1,29 @@ +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 index 0000000000..8c682cdaa2 --- /dev/null +++ b/src/applications/herald/field/HeraldNewObjectField.php @@ -0,0 +1,27 @@ +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 index 72850bf94a..6d7de8ba99 100644 --- a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php +++ b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php @@ -12,6 +12,10 @@ final class PhrictionDocumentHeraldAdapter extends HeraldAdapter { 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 @@ final class PhrictionDocumentHeraldAdapter extends HeraldAdapter { 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 index 0000000000..c73ca50919 --- /dev/null +++ b/src/applications/project/herald/HeraldProjectsField.php @@ -0,0 +1,35 @@ +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 index 0000000000..a9afc016d5 --- /dev/null +++ b/src/applications/spaces/herald/HeraldSpaceField.php @@ -0,0 +1,27 @@ +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; + } + } + +}