mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12: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:
parent
fc72b000f0
commit
b2b739c709
85 changed files with 143 additions and 297 deletions
|
@ -13,18 +13,8 @@ final class DifferentialDiffAffectedFilesHeraldField
|
|||
return $this->getAdapter()->loadAffectedPaths();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DifferentialDiffAuthorHeraldField
|
|||
return $object->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DifferentialDiffAuthorProjectsHeraldField
|
|||
PhabricatorProjectMemberOfProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialDiffContentAddedHeraldField
|
|||
return $this->getAdapter()->loadAddedContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialDiffContentHeraldField
|
|||
return $this->getAdapter()->loadContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialDiffContentRemovedHeraldField
|
|||
return $this->getAdapter()->loadRemovedContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ final class DifferentialDiffRepositoryHeraldField
|
|||
return $repository->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ final class DifferentialDiffRepositoryProjectsHeraldField
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,18 +13,8 @@ final class DifferentialRevisionAffectedFilesHeraldField
|
|||
return $this->getAdapter()->loadAffectedPaths();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DifferentialRevisionAuthorHeraldField
|
|||
return $object->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DifferentialRevisionAuthorProjectsHeraldField
|
|||
PhabricatorProjectMemberOfProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialRevisionContentAddedHeraldField
|
|||
return $this->getAdapter()->loadAddedContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialRevisionContentHeraldField
|
|||
return $this->getAdapter()->loadContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialRevisionContentRemovedHeraldField
|
|||
return $this->getAdapter()->loadRemovedContentDictionary();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ final class DifferentialRevisionPackageHeraldField
|
|||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -19,8 +19,8 @@ final class DifferentialRevisionPackageOwnerHeraldField
|
|||
return mpull($owners, 'getUserPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -19,7 +19,7 @@ final class DifferentialRevisionRepositoryHeraldField
|
|||
return $repository->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ final class DifferentialRevisionRepositoryProjectsHeraldField
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,8 +13,8 @@ final class DifferentialRevisionReviewersHeraldField
|
|||
return $this->getAdapter()->loadReviewers();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -16,12 +16,8 @@ final class DifferentialRevisionSummaryHeraldField
|
|||
return $object->getSummary()."\n\n".$object->getTestPlan();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DifferentialRevisionTitleHeraldField
|
|||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitAffectedFilesHeraldField
|
|||
return $this->getAdapter()->loadAffectedPaths();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionCommitAuthorHeraldField
|
|||
return $object->getCommitData()->getCommitDetail('authorPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,8 @@ final class DiffusionCommitBranchesHeraldField
|
|||
return mpull($refs, 'getShortName');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionCommitCommitterHeraldField
|
|||
return $object->getCommitData()->getCommitDetail('committerPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentAddedHeraldField
|
|||
return $this->getAdapter()->loadDiffContent('+');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentHeraldField
|
|||
return $this->getAdapter()->loadDiffContent('*');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitDiffContentRemovedHeraldField
|
|||
return $this->getAdapter()->loadDiffContent('-');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitDiffEnormousHeraldField
|
|||
return $this->getAdapter()->isDiffEnormous();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionCommitMessageHeraldField
|
|||
return $object->getCommitData()->getCommitMessage();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ final class DiffusionCommitPackageAuditHeraldField
|
|||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -14,8 +14,8 @@ final class DiffusionCommitPackageHeraldField
|
|||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -20,8 +20,8 @@ final class DiffusionCommitPackageOwnerHeraldField
|
|||
return mpull($owners, 'getUserPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionCommitRepositoryHeraldField
|
|||
return $object->getRepository()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DiffusionCommitRepositoryProjectsHeraldField
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionCommitReviewerHeraldField
|
|||
return $object->getCommitData()->getCommitDetail('reviewerPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,8 @@ final class DiffusionCommitRevisionAcceptedHeraldField
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,8 @@ final class DiffusionCommitRevisionHeraldField
|
|||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ final class DiffusionCommitRevisionReviewersHeraldField
|
|||
return $revision->getReviewers();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -20,8 +20,8 @@ final class DiffusionCommitRevisionSubscribersHeraldField
|
|||
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentAffectedFilesHeraldField
|
|||
return $this->getAdapter()->getDiffContent('name');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitContentAuthorHeraldField
|
|||
return $this->getAdapter()->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentAuthorRawHeraldField
|
|||
return $this->getAdapter()->getAuthorRaw();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentBranchesHeraldField
|
|||
return $this->getAdapter()->getBranches();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitContentCommitterHeraldField
|
|||
return $this->getAdapter()->getCommitterPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentCommitterRawHeraldField
|
|||
return $this->getAdapter()->getCommitterRaw();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentAddedHeraldField
|
|||
return $this->getAdapter()->getDiffContent('+');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentHeraldField
|
|||
return $this->getAdapter()->getDiffContent('*');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffContentRemovedHeraldField
|
|||
return $this->getAdapter()->getDiffContent('-');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentDiffEnormousHeraldField
|
|||
return $this->getAdapter()->isDiffEnormous();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentMergeHeraldField
|
|||
return $this->getAdapter()->getIsMergeCommit();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitContentMessageHeraldField
|
|||
return $this->getAdapter()->getCommitRef()->getMessage();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitContentPusherHeraldField
|
|||
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,8 @@ final class DiffusionPreCommitContentPusherIsCommitterHeraldField
|
|||
return ($pusher === $committer);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DiffusionPreCommitContentPusherProjectsHeraldField
|
|||
->loadViewerProjectPHIDsForHerald();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return HeraldField::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitContentRepositoryHeraldField
|
|||
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DiffusionPreCommitContentRepositoryProjectsHeraldField
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return HeraldField::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -24,12 +24,8 @@ final class DiffusionPreCommitContentRevisionAcceptedHeraldField
|
|||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,8 @@ final class DiffusionPreCommitContentRevisionHeraldField
|
|||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ final class DiffusionPreCommitContentRevisionReviewersHeraldField
|
|||
return $revision->getReviewers();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -20,8 +20,8 @@ final class DiffusionPreCommitContentRevisionSubscribersHeraldField
|
|||
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,12 +13,8 @@ final class DiffusionPreCommitRefNameHeraldField
|
|||
return $object->getRefName();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitRefPusherHeraldField
|
|||
return $this->getAdapter()->getHookEngine()->getViewer()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DiffusionPreCommitRefPusherProjectsHeraldField
|
|||
->loadViewerProjectPHIDsForHerald();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return HeraldField::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class DiffusionPreCommitRefRepositoryHeraldField
|
|||
return $this->getAdapter()->getHookEngine()->getRepository()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ final class DiffusionPreCommitRefRepositoryProjectsHeraldField
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return HeraldField::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -4,28 +4,25 @@ abstract class HeraldField extends Phobject {
|
|||
|
||||
private $adapter;
|
||||
|
||||
const STANDARD_LIST = 'standard.list';
|
||||
const STANDARD_BOOL = 'standard.bool';
|
||||
const STANDARD_TEXT = 'standard.text';
|
||||
const STANDARD_TEXT_LIST = 'standard.text.list';
|
||||
const STANDARD_TEXT_MAP = 'standard.text.map';
|
||||
const STANDARD_PHID = 'standard.phid';
|
||||
const STANDARD_PHID_LIST = 'standard.phid.list';
|
||||
const STANDARD_PHID_BOOL = 'standard.phid.bool';
|
||||
const STANDARD_PHID_NULLABLE = 'standard.phid.nullable';
|
||||
|
||||
abstract public function getHeraldFieldName();
|
||||
abstract public function getHeraldFieldValue($object);
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
throw new PhutilMethodNotImplementedException();
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
$standard_type = $this->getHeraldFieldStandardType();
|
||||
switch ($standard_type) {
|
||||
case self::STANDARD_BOOL:
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_IS_TRUE,
|
||||
|
@ -44,6 +41,14 @@ abstract class HeraldField extends Phobject {
|
|||
HeraldAdapter::CONDITION_IS_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:
|
||||
return array(
|
||||
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() {
|
||||
throw new PhutilMethodNotImplementedException();
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
$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);
|
||||
|
||||
|
|
|
@ -16,12 +16,8 @@ final class HeraldNewObjectField extends HeraldField {
|
|||
return $this->getAdapter()->getIsNewObject();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class ManiphestTaskAssigneeHeraldField
|
|||
return $object->getOwnerPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ final class ManiphestTaskAuthorHeraldField
|
|||
return $object->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class ManiphestTaskDescriptionHeraldField
|
|||
return $object->getDescription();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class ManiphestTaskPriorityHeraldField
|
|||
return $object->getPriority();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ final class ManiphestTaskStatusHeraldField
|
|||
return $object->getStatus();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class ManiphestTaskTitleHeraldField
|
|||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ final class PhabricatorMetaMTAApplicationEmailHeraldField
|
|||
return $phids;
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class PholioMockAuthorHeraldField
|
|||
return $object->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class PholioMockDescriptionHeraldField
|
|||
return $object->getDescription();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class PholioMockNameHeraldField
|
|||
return $object->getName();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final class PhrictionDocumentAuthorHeraldField
|
|||
return $object->getContent()->getAuthorPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,8 @@ final class PhrictionDocumentContentHeraldField
|
|||
return $object->getContent()->getContent();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class PhrictionDocumentPathHeraldField
|
|||
return $object->getcontent()->getSlug();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,8 @@ final class PhrictionDocumentTitleHeraldField
|
|||
return $object->getContent()->getTitle();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ final class HeraldProjectsField extends HeraldField {
|
|||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
|
@ -16,7 +16,7 @@ final class HeraldSpaceField extends HeraldField {
|
|||
return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ final class HeraldSubscribersField extends HeraldField {
|
|||
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
|
|
Loading…
Reference in a new issue