1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Reduce code duplication in Herald fields

Summary:
Ref T8726. I want to modularize values and reduce how hard-coded / copypasta'd they are.

  - Rename `get...StandardCondition()` to `get...StandardType()`, since we can drive both conditions and values from it.
  - Rename `STANDARD_LIST` to `STANDARD_PHID_LIST` for consistency: all "lists" are lists of PHIDs.
  - For all standard types which don't require typehaeads, lift their logic into the base class.
  - I'll lift typeaheads soon, but need to generalize them first.

Test Plan: Edited various Herald rules, saw value UI generate correctly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13612
This commit is contained in:
epriestley 2015-07-16 14:11:44 -07:00
parent fc72b000f0
commit b2b739c709
85 changed files with 143 additions and 297 deletions

View file

@ -13,18 +13,8 @@ final class DifferentialDiffAffectedFilesHeraldField
return $this->getAdapter()->loadAffectedPaths(); return $this->getAdapter()->loadAffectedPaths();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
switch ($condition) {
case HeraldAdapter::CONDITION_EXISTS:
case HeraldAdapter::CONDITION_NOT_EXISTS:
return HeraldAdapter::VALUE_NONE;
default:
return HeraldAdapter::VALUE_TEXT;
}
}
} }

View file

@ -13,7 +13,7 @@ final class DifferentialDiffAuthorHeraldField
return $object->getAuthorPHID(); return $object->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DifferentialDiffAuthorProjectsHeraldField
PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); PhabricatorProjectMemberOfProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,12 +13,8 @@ final class DifferentialDiffContentAddedHeraldField
return $this->getAdapter()->loadAddedContentDictionary(); return $this->getAdapter()->loadAddedContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DifferentialDiffContentHeraldField
return $this->getAdapter()->loadContentDictionary(); return $this->getAdapter()->loadContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DifferentialDiffContentRemovedHeraldField
return $this->getAdapter()->loadRemovedContentDictionary(); return $this->getAdapter()->loadRemovedContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -19,7 +19,7 @@ final class DifferentialDiffRepositoryHeraldField
return $repository->getPHID(); return $repository->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -20,8 +20,8 @@ final class DifferentialDiffRepositoryProjectsHeraldField
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,18 +13,8 @@ final class DifferentialRevisionAffectedFilesHeraldField
return $this->getAdapter()->loadAffectedPaths(); return $this->getAdapter()->loadAffectedPaths();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
switch ($condition) {
case HeraldAdapter::CONDITION_EXISTS:
case HeraldAdapter::CONDITION_NOT_EXISTS:
return HeraldAdapter::VALUE_NONE;
default:
return HeraldAdapter::VALUE_TEXT;
}
}
} }

View file

@ -13,7 +13,7 @@ final class DifferentialRevisionAuthorHeraldField
return $object->getAuthorPHID(); return $object->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DifferentialRevisionAuthorProjectsHeraldField
PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); PhabricatorProjectMemberOfProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,12 +13,8 @@ final class DifferentialRevisionContentAddedHeraldField
return $this->getAdapter()->loadAddedContentDictionary(); return $this->getAdapter()->loadAddedContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DifferentialRevisionContentHeraldField
return $this->getAdapter()->loadContentDictionary(); return $this->getAdapter()->loadContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DifferentialRevisionContentRemovedHeraldField
return $this->getAdapter()->loadRemovedContentDictionary(); return $this->getAdapter()->loadRemovedContentDictionary();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -14,8 +14,8 @@ final class DifferentialRevisionPackageHeraldField
return mpull($packages, 'getPHID'); return mpull($packages, 'getPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -19,8 +19,8 @@ final class DifferentialRevisionPackageOwnerHeraldField
return mpull($owners, 'getUserPHID'); return mpull($owners, 'getUserPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -19,7 +19,7 @@ final class DifferentialRevisionRepositoryHeraldField
return $repository->getPHID(); return $repository->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -20,8 +20,8 @@ final class DifferentialRevisionRepositoryProjectsHeraldField
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,8 +13,8 @@ final class DifferentialRevisionReviewersHeraldField
return $this->getAdapter()->loadReviewers(); return $this->getAdapter()->loadReviewers();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -16,12 +16,8 @@ final class DifferentialRevisionSummaryHeraldField
return $object->getSummary()."\n\n".$object->getTestPlan(); return $object->getSummary()."\n\n".$object->getTestPlan();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DifferentialRevisionTitleHeraldField
return $object->getTitle(); return $object->getTitle();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitAffectedFilesHeraldField
return $this->getAdapter()->loadAffectedPaths(); return $this->getAdapter()->loadAffectedPaths();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionCommitAuthorHeraldField
return $object->getCommitData()->getCommitDetail('authorPHID'); return $object->getCommitData()->getCommitDetail('authorPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -27,12 +27,8 @@ final class DiffusionCommitBranchesHeraldField
return mpull($refs, 'getShortName'); return mpull($refs, 'getShortName');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionCommitCommitterHeraldField
return $object->getCommitData()->getCommitDetail('committerPHID'); return $object->getCommitData()->getCommitDetail('committerPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentAddedHeraldField
return $this->getAdapter()->loadDiffContent('+'); return $this->getAdapter()->loadDiffContent('+');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentHeraldField
return $this->getAdapter()->loadDiffContent('*'); return $this->getAdapter()->loadDiffContent('*');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentRemovedHeraldField
return $this->getAdapter()->loadDiffContent('-'); return $this->getAdapter()->loadDiffContent('-');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitDiffEnormousHeraldField
return $this->getAdapter()->isDiffEnormous(); return $this->getAdapter()->isDiffEnormous();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL; return self::STANDARD_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionCommitMessageHeraldField
return $object->getCommitData()->getCommitMessage(); return $object->getCommitData()->getCommitMessage();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -18,8 +18,8 @@ final class DiffusionCommitPackageAuditHeraldField
return mpull($packages, 'getPHID'); return mpull($packages, 'getPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -14,8 +14,8 @@ final class DiffusionCommitPackageHeraldField
return mpull($packages, 'getPHID'); return mpull($packages, 'getPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -20,8 +20,8 @@ final class DiffusionCommitPackageOwnerHeraldField
return mpull($owners, 'getUserPHID'); return mpull($owners, 'getUserPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,7 +13,7 @@ final class DiffusionCommitRepositoryHeraldField
return $object->getRepository()->getPHID(); return $object->getRepository()->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DiffusionCommitRepositoryProjectsHeraldField
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,7 +13,7 @@ final class DiffusionCommitReviewerHeraldField
return $object->getCommitData()->getCommitDetail('reviewerPHID'); return $object->getCommitData()->getCommitDetail('reviewerPHID');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -29,12 +29,8 @@ final class DiffusionCommitRevisionAcceptedHeraldField
return null; return null;
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL; return self::STANDARD_PHID_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -19,12 +19,8 @@ final class DiffusionCommitRevisionHeraldField
return $revision->getPHID(); return $revision->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL; return self::STANDARD_PHID_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -19,8 +19,8 @@ final class DiffusionCommitRevisionReviewersHeraldField
return $revision->getReviewers(); return $revision->getReviewers();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -20,8 +20,8 @@ final class DiffusionCommitRevisionSubscribersHeraldField
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentAffectedFilesHeraldField
return $this->getAdapter()->getDiffContent('name'); return $this->getAdapter()->getDiffContent('name');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitContentAuthorHeraldField
return $this->getAdapter()->getAuthorPHID(); return $this->getAdapter()->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentAuthorRawHeraldField
return $this->getAdapter()->getAuthorRaw(); return $this->getAdapter()->getAuthorRaw();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentBranchesHeraldField
return $this->getAdapter()->getBranches(); return $this->getAdapter()->getBranches();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST; return self::STANDARD_TEXT_LIST;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitContentCommitterHeraldField
return $this->getAdapter()->getCommitterPHID(); return $this->getAdapter()->getCommitterPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentCommitterRawHeraldField
return $this->getAdapter()->getCommitterRaw(); return $this->getAdapter()->getCommitterRaw();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentAddedHeraldField
return $this->getAdapter()->getDiffContent('+'); return $this->getAdapter()->getDiffContent('+');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentHeraldField
return $this->getAdapter()->getDiffContent('*'); return $this->getAdapter()->getDiffContent('*');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentRemovedHeraldField
return $this->getAdapter()->getDiffContent('-'); return $this->getAdapter()->getDiffContent('-');
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_MAP; return self::STANDARD_TEXT_MAP;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffEnormousHeraldField
return $this->getAdapter()->isDiffEnormous(); return $this->getAdapter()->isDiffEnormous();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL; return HeraldField::STANDARD_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentMergeHeraldField
return $this->getAdapter()->getIsMergeCommit(); return $this->getAdapter()->getIsMergeCommit();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL; return HeraldField::STANDARD_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitContentMessageHeraldField
return $this->getAdapter()->getCommitRef()->getMessage(); return $this->getAdapter()->getCommitRef()->getMessage();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitContentPusherHeraldField
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID; return HeraldField::STANDARD_PHID;
} }

View file

@ -16,12 +16,8 @@ final class DiffusionPreCommitContentPusherIsCommitterHeraldField
return ($pusher === $committer); return ($pusher === $committer);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_BOOL; return HeraldField::STANDARD_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -15,8 +15,8 @@ final class DiffusionPreCommitContentPusherProjectsHeraldField
->loadViewerProjectPHIDsForHerald(); ->loadViewerProjectPHIDsForHerald();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_LIST; return HeraldField::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitContentRepositoryHeraldField
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID(); return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID; return HeraldField::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DiffusionPreCommitContentRepositoryProjectsHeraldField
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_LIST; return HeraldField::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -24,12 +24,8 @@ final class DiffusionPreCommitContentRevisionAcceptedHeraldField
return $revision->getPHID(); return $revision->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL; return self::STANDARD_PHID_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -19,12 +19,8 @@ final class DiffusionPreCommitContentRevisionHeraldField
return $revision->getPHID(); return $revision->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_BOOL; return self::STANDARD_PHID_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -19,8 +19,8 @@ final class DiffusionPreCommitContentRevisionReviewersHeraldField
return $revision->getReviewers(); return $revision->getReviewers();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -20,8 +20,8 @@ final class DiffusionPreCommitContentRevisionSubscribersHeraldField
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,12 +13,8 @@ final class DiffusionPreCommitRefNameHeraldField
return $object->getRefName(); return $object->getRefName();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_TEXT; return HeraldField::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitRefPusherHeraldField
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID; return HeraldField::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DiffusionPreCommitRefPusherProjectsHeraldField
->loadViewerProjectPHIDsForHerald(); ->loadViewerProjectPHIDsForHerald();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_LIST; return HeraldField::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,7 +13,7 @@ final class DiffusionPreCommitRefRepositoryHeraldField
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID(); return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_PHID; return HeraldField::STANDARD_PHID;
} }

View file

@ -15,8 +15,8 @@ final class DiffusionPreCommitRefRepositoryProjectsHeraldField
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return HeraldField::STANDARD_LIST; return HeraldField::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -4,28 +4,25 @@ abstract class HeraldField extends Phobject {
private $adapter; private $adapter;
const STANDARD_LIST = 'standard.list';
const STANDARD_BOOL = 'standard.bool'; const STANDARD_BOOL = 'standard.bool';
const STANDARD_TEXT = 'standard.text'; const STANDARD_TEXT = 'standard.text';
const STANDARD_TEXT_LIST = 'standard.text.list'; const STANDARD_TEXT_LIST = 'standard.text.list';
const STANDARD_TEXT_MAP = 'standard.text.map'; const STANDARD_TEXT_MAP = 'standard.text.map';
const STANDARD_PHID = 'standard.phid'; const STANDARD_PHID = 'standard.phid';
const STANDARD_PHID_LIST = 'standard.phid.list';
const STANDARD_PHID_BOOL = 'standard.phid.bool'; const STANDARD_PHID_BOOL = 'standard.phid.bool';
const STANDARD_PHID_NULLABLE = 'standard.phid.nullable'; const STANDARD_PHID_NULLABLE = 'standard.phid.nullable';
abstract public function getHeraldFieldName(); abstract public function getHeraldFieldName();
abstract public function getHeraldFieldValue($object); abstract public function getHeraldFieldValue($object);
protected function getHeraldFieldStandardType() {
throw new PhutilMethodNotImplementedException();
}
public function getHeraldFieldConditions() { public function getHeraldFieldConditions() {
switch ($this->getHeraldFieldStandardConditions()) { $standard_type = $this->getHeraldFieldStandardType();
case self::STANDARD_LIST: switch ($standard_type) {
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: case self::STANDARD_BOOL:
return array( return array(
HeraldAdapter::CONDITION_IS_TRUE, HeraldAdapter::CONDITION_IS_TRUE,
@ -44,6 +41,14 @@ abstract class HeraldField extends Phobject {
HeraldAdapter::CONDITION_IS_ANY, HeraldAdapter::CONDITION_IS_ANY,
HeraldAdapter::CONDITION_IS_NOT_ANY, HeraldAdapter::CONDITION_IS_NOT_ANY,
); );
case self::STANDARD_PHID_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_PHID_BOOL: case self::STANDARD_PHID_BOOL:
return array( return array(
HeraldAdapter::CONDITION_EXISTS, HeraldAdapter::CONDITION_EXISTS,
@ -69,14 +74,31 @@ abstract class HeraldField extends Phobject {
); );
} }
throw new Exception(pht('Unknown standard condition set.')); throw new Exception(
pht(
'Herald field "%s" has unknown standard type "%s".',
get_class($this),
$standard_type));
} }
protected function getHeraldFieldStandardConditions() { public function getHeraldFieldValueType($condition) {
throw new PhutilMethodNotImplementedException(); $standard_type = $this->getHeraldFieldStandardType();
} switch ($standard_type) {
case self::STANDARD_BOOL:
case self::STANDARD_PHID_BOOL:
return HeraldAdapter::VALUE_NONE;
case self::STANDARD_TEXT:
case self::STANDARD_TEXT_LIST:
case self::STANDARD_TEXT_MAP:
return HeraldAdapter::VALUE_TEXT;
}
abstract public function getHeraldFieldValueType($condition); throw new Exception(
pht(
'Herald field "%s" has unknown standard type "%s".',
get_class($this),
$standard_type));
}
abstract public function supportsObject($object); abstract public function supportsObject($object);

View file

@ -16,12 +16,8 @@ final class HeraldNewObjectField extends HeraldField {
return $this->getAdapter()->getIsNewObject(); return $this->getAdapter()->getIsNewObject();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_BOOL; return self::STANDARD_BOOL;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_NONE;
}
} }

View file

@ -13,7 +13,7 @@ final class ManiphestTaskAssigneeHeraldField
return $object->getOwnerPHID(); return $object->getOwnerPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_NULLABLE; return self::STANDARD_PHID_NULLABLE;
} }

View file

@ -13,7 +13,7 @@ final class ManiphestTaskAuthorHeraldField
return $object->getAuthorPHID(); return $object->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -13,12 +13,8 @@ final class ManiphestTaskDescriptionHeraldField
return $object->getDescription(); return $object->getDescription();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class ManiphestTaskPriorityHeraldField
return $object->getPriority(); return $object->getPriority();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -13,7 +13,7 @@ final class ManiphestTaskStatusHeraldField
return $object->getStatus(); return $object->getStatus();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -13,12 +13,8 @@ final class ManiphestTaskTitleHeraldField
return $object->getTitle(); return $object->getTitle();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -24,8 +24,8 @@ final class PhabricatorMetaMTAApplicationEmailHeraldField
return $phids; return $phids;
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -13,7 +13,7 @@ final class PholioMockAuthorHeraldField
return $object->getAuthorPHID(); return $object->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -13,12 +13,8 @@ final class PholioMockDescriptionHeraldField
return $object->getDescription(); return $object->getDescription();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class PholioMockNameHeraldField
return $object->getName(); return $object->getName();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,7 +13,7 @@ final class PhrictionDocumentAuthorHeraldField
return $object->getContent()->getAuthorPHID(); return $object->getContent()->getAuthorPHID();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -13,12 +13,8 @@ final class PhrictionDocumentContentHeraldField
return $object->getContent()->getContent(); return $object->getContent()->getContent();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class PhrictionDocumentPathHeraldField
return $object->getcontent()->getSlug(); return $object->getcontent()->getSlug();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -13,12 +13,8 @@ final class PhrictionDocumentTitleHeraldField
return $object->getContent()->getTitle(); return $object->getContent()->getTitle();
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT; return self::STANDARD_TEXT;
} }
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TEXT;
}
} }

View file

@ -18,8 +18,8 @@ final class HeraldProjectsField extends HeraldField {
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {

View file

@ -16,7 +16,7 @@ final class HeraldSpaceField extends HeraldField {
return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object); return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID; return self::STANDARD_PHID;
} }

View file

@ -17,8 +17,8 @@ final class HeraldSubscribersField extends HeraldField {
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
} }
protected function getHeraldFieldStandardConditions() { protected function getHeraldFieldStandardType() {
return self::STANDARD_LIST; return self::STANDARD_PHID_LIST;
} }
public function getHeraldFieldValueType($condition) { public function getHeraldFieldValueType($condition) {