mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-05 03:18:25 +01:00
Modularize more Herald fields
Summary: Ref T8726. Continue making Herald fields more modular than they currently are. Test Plan: - Created a rule using all the affected fields. - Ran the rule. - Saw reasonable object field values. Reviewers: btrahan Reviewed By: btrahan Subscribers: eadler, joshuaspence, epriestley Maniphest Tasks: T8726 Differential Revision: https://secure.phabricator.com/D13495
This commit is contained in:
parent
b266412f3e
commit
59c294457f
18 changed files with 287 additions and 93 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
29
src/applications/herald/field/HeraldAlwaysField.php
Normal file
29
src/applications/herald/field/HeraldAlwaysField.php
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
31
src/applications/herald/field/HeraldAnotherRuleField.php
Normal file
31
src/applications/herald/field/HeraldAnotherRuleField.php
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -4,9 +4,43 @@ abstract class HeraldField extends Phobject {
|
|||
|
||||
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);
|
||||
|
|
27
src/applications/herald/field/HeraldNewObjectField.php
Normal file
27
src/applications/herald/field/HeraldNewObjectField.php
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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());
|
||||
|
|
35
src/applications/project/herald/HeraldProjectsField.php
Normal file
35
src/applications/project/herald/HeraldProjectsField.php
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
27
src/applications/spaces/herald/HeraldSpaceField.php
Normal file
27
src/applications/spaces/herald/HeraldSpaceField.php
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue