@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+143 -297
+1 -11
src/applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php
··· 13 13 return $this->getAdapter()->loadAffectedPaths(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_LIST; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_TEXT; 27 - } 28 18 } 29 19 30 20 }
+1 -1
src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php
··· 13 13 return $object->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php
··· 15 15 PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return self::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/differential/herald/DifferentialDiffContentAddedHeraldField.php
··· 13 13 return $this->getAdapter()->loadAddedContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/differential/herald/DifferentialDiffContentHeraldField.php
··· 13 13 return $this->getAdapter()->loadContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php
··· 13 13 return $this->getAdapter()->loadRemovedContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
··· 19 19 return $repository->getPHID(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 22 + protected function getHeraldFieldStandardType() { 23 23 return self::STANDARD_PHID_NULLABLE; 24 24 } 25 25
+2 -2
src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php
··· 20 20 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 21 21 } 22 22 23 - protected function getHeraldFieldStandardConditions() { 24 - return self::STANDARD_LIST; 23 + protected function getHeraldFieldStandardType() { 24 + return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 27 public function getHeraldFieldValueType($condition) {
+1 -11
src/applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php
··· 13 13 return $this->getAdapter()->loadAffectedPaths(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_LIST; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_TEXT; 27 - } 28 18 } 29 19 30 20 }
+1 -1
src/applications/differential/herald/DifferentialRevisionAuthorHeraldField.php
··· 13 13 return $object->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php
··· 15 15 PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return self::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/differential/herald/DifferentialRevisionContentAddedHeraldField.php
··· 13 13 return $this->getAdapter()->loadAddedContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/differential/herald/DifferentialRevisionContentHeraldField.php
··· 13 13 return $this->getAdapter()->loadContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/differential/herald/DifferentialRevisionContentRemovedHeraldField.php
··· 13 13 return $this->getAdapter()->loadRemovedContentDictionary(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+2 -2
src/applications/differential/herald/DifferentialRevisionPackageHeraldField.php
··· 14 14 return mpull($packages, 'getPHID'); 15 15 } 16 16 17 - protected function getHeraldFieldStandardConditions() { 18 - return self::STANDARD_LIST; 17 + protected function getHeraldFieldStandardType() { 18 + return self::STANDARD_PHID_LIST; 19 19 } 20 20 21 21 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php
··· 19 19 return mpull($owners, 'getUserPHID'); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 23 - return self::STANDARD_LIST; 22 + protected function getHeraldFieldStandardType() { 23 + return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 26 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php
··· 19 19 return $repository->getPHID(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 22 + protected function getHeraldFieldStandardType() { 23 23 return self::STANDARD_PHID_NULLABLE; 24 24 } 25 25
+2 -2
src/applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php
··· 20 20 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 21 21 } 22 22 23 - protected function getHeraldFieldStandardConditions() { 24 - return self::STANDARD_LIST; 23 + protected function getHeraldFieldStandardType() { 24 + return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 27 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/differential/herald/DifferentialRevisionReviewersHeraldField.php
··· 13 13 return $this->getAdapter()->loadReviewers(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 17 - return self::STANDARD_LIST; 16 + protected function getHeraldFieldStandardType() { 17 + return self::STANDARD_PHID_LIST; 18 18 } 19 19 20 20 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/differential/herald/DifferentialRevisionSummaryHeraldField.php
··· 16 16 return $object->getSummary()."\n\n".$object->getTestPlan(); 17 17 } 18 18 19 - protected function getHeraldFieldStandardConditions() { 19 + protected function getHeraldFieldStandardType() { 20 20 return self::STANDARD_TEXT; 21 - } 22 - 23 - public function getHeraldFieldValueType($condition) { 24 - return HeraldAdapter::VALUE_TEXT; 25 21 } 26 22 27 23 }
+1 -5
src/applications/differential/herald/DifferentialRevisionTitleHeraldField.php
··· 13 13 return $object->getTitle(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php
··· 13 13 return $this->getAdapter()->loadAffectedPaths(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_LIST; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php
··· 13 13 return $object->getCommitData()->getCommitDetail('authorPHID'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionCommitBranchesHeraldField.php
··· 27 27 return mpull($refs, 'getShortName'); 28 28 } 29 29 30 - protected function getHeraldFieldStandardConditions() { 30 + protected function getHeraldFieldStandardType() { 31 31 return self::STANDARD_TEXT_LIST; 32 - } 33 - 34 - public function getHeraldFieldValueType($condition) { 35 - return HeraldAdapter::VALUE_TEXT; 36 32 } 37 33 38 34 }
+1 -1
src/applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php
··· 13 13 return $object->getCommitData()->getCommitDetail('committerPHID'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionCommitDiffContentAddedHeraldField.php
··· 13 13 return $this->getAdapter()->loadDiffContent('+'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitDiffContentHeraldField.php
··· 13 13 return $this->getAdapter()->loadDiffContent('*'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitDiffContentRemovedHeraldField.php
··· 13 13 return $this->getAdapter()->loadDiffContent('-'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitDiffEnormousHeraldField.php
··· 13 13 return $this->getAdapter()->isDiffEnormous(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_BOOL; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_NONE; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitMessageHeraldField.php
··· 13 13 return $object->getCommitData()->getCommitMessage(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+2 -2
src/applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php
··· 18 18 return mpull($packages, 'getPHID'); 19 19 } 20 20 21 - protected function getHeraldFieldStandardConditions() { 22 - return self::STANDARD_LIST; 21 + protected function getHeraldFieldStandardType() { 22 + return self::STANDARD_PHID_LIST; 23 23 } 24 24 25 25 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/diffusion/herald/DiffusionCommitPackageHeraldField.php
··· 14 14 return mpull($packages, 'getPHID'); 15 15 } 16 16 17 - protected function getHeraldFieldStandardConditions() { 18 - return self::STANDARD_LIST; 17 + protected function getHeraldFieldStandardType() { 18 + return self::STANDARD_PHID_LIST; 19 19 } 20 20 21 21 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php
··· 20 20 return mpull($owners, 'getUserPHID'); 21 21 } 22 22 23 - protected function getHeraldFieldStandardConditions() { 24 - return self::STANDARD_LIST; 23 + protected function getHeraldFieldStandardType() { 24 + return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 27 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/diffusion/herald/DiffusionCommitRepositoryHeraldField.php
··· 13 13 return $object->getRepository()->getPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/diffusion/herald/DiffusionCommitRepositoryProjectsHeraldField.php
··· 15 15 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return self::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/diffusion/herald/DiffusionCommitReviewerHeraldField.php
··· 13 13 return $object->getCommitData()->getCommitDetail('reviewerPHID'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php
··· 29 29 return null; 30 30 } 31 31 32 - protected function getHeraldFieldStandardConditions() { 32 + protected function getHeraldFieldStandardType() { 33 33 return self::STANDARD_PHID_BOOL; 34 - } 35 - 36 - public function getHeraldFieldValueType($condition) { 37 - return HeraldAdapter::VALUE_NONE; 38 34 } 39 35 40 36 }
+1 -5
src/applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php
··· 19 19 return $revision->getPHID(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 22 + protected function getHeraldFieldStandardType() { 23 23 return self::STANDARD_PHID_BOOL; 24 - } 25 - 26 - public function getHeraldFieldValueType($condition) { 27 - return HeraldAdapter::VALUE_NONE; 28 24 } 29 25 30 26 }
+2 -2
src/applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php
··· 19 19 return $revision->getReviewers(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 23 - return self::STANDARD_LIST; 22 + protected function getHeraldFieldStandardType() { 23 + return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 26 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php
··· 20 20 return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); 21 21 } 22 22 23 - protected function getHeraldFieldStandardConditions() { 24 - return self::STANDARD_LIST; 23 + protected function getHeraldFieldStandardType() { 24 + return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 27 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php
··· 13 13 return $this->getAdapter()->getDiffContent('name'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_LIST; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php
··· 13 13 return $this->getAdapter()->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php
··· 13 13 return $this->getAdapter()->getAuthorRaw(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php
··· 13 13 return $this->getAdapter()->getBranches(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_LIST; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php
··· 13 13 return $this->getAdapter()->getCommitterPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php
··· 13 13 return $this->getAdapter()->getCommitterRaw(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php
··· 13 13 return $this->getAdapter()->getDiffContent('+'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php
··· 13 13 return $this->getAdapter()->getDiffContent('*'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentRemovedHeraldField.php
··· 13 13 return $this->getAdapter()->getDiffContent('-'); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT_MAP; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentDiffEnormousHeraldField.php
··· 13 13 return $this->getAdapter()->isDiffEnormous(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_BOOL; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_NONE; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php
··· 13 13 return $this->getAdapter()->getIsMergeCommit(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_BOOL; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_NONE; 22 18 } 23 19 24 20 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php
··· 13 13 return $this->getAdapter()->getCommitRef()->getMessage(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php
··· 13 13 return $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php
··· 16 16 return ($pusher === $committer); 17 17 } 18 18 19 - protected function getHeraldFieldStandardConditions() { 19 + protected function getHeraldFieldStandardType() { 20 20 return HeraldField::STANDARD_BOOL; 21 - } 22 - 23 - public function getHeraldFieldValueType($condition) { 24 - return HeraldAdapter::VALUE_NONE; 25 21 } 26 22 27 23 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php
··· 15 15 ->loadViewerProjectPHIDsForHerald(); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return HeraldField::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php
··· 13 13 return $this->getAdapter()->getHookEngine()->getRepository()->getPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php
··· 15 15 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return HeraldField::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php
··· 24 24 return $revision->getPHID(); 25 25 } 26 26 27 - protected function getHeraldFieldStandardConditions() { 27 + protected function getHeraldFieldStandardType() { 28 28 return self::STANDARD_PHID_BOOL; 29 - } 30 - 31 - public function getHeraldFieldValueType($condition) { 32 - return HeraldAdapter::VALUE_NONE; 33 29 } 34 30 35 31 }
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionHeraldField.php
··· 19 19 return $revision->getPHID(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 22 + protected function getHeraldFieldStandardType() { 23 23 return self::STANDARD_PHID_BOOL; 24 - } 25 - 26 - public function getHeraldFieldValueType($condition) { 27 - return HeraldAdapter::VALUE_NONE; 28 24 } 29 25 30 26 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php
··· 19 19 return $revision->getReviewers(); 20 20 } 21 21 22 - protected function getHeraldFieldStandardConditions() { 23 - return self::STANDARD_LIST; 22 + protected function getHeraldFieldStandardType() { 23 + return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 26 public function getHeraldFieldValueType($condition) {
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php
··· 20 20 return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); 21 21 } 22 22 23 - protected function getHeraldFieldStandardConditions() { 24 - return self::STANDARD_LIST; 23 + protected function getHeraldFieldStandardType() { 24 + return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 27 public function getHeraldFieldValueType($condition) {
+1 -5
src/applications/diffusion/herald/DiffusionPreCommitRefNameHeraldField.php
··· 13 13 return $object->getRefName(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitRefPusherHeraldField.php
··· 13 13 return $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitRefPusherProjectsHeraldField.php
··· 15 15 ->loadViewerProjectPHIDsForHerald(); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return HeraldField::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryHeraldField.php
··· 13 13 return $this->getAdapter()->getHookEngine()->getRepository()->getPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryProjectsHeraldField.php
··· 15 15 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 16 16 } 17 17 18 - protected function getHeraldFieldStandardConditions() { 19 - return HeraldField::STANDARD_LIST; 18 + protected function getHeraldFieldStandardType() { 19 + return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) {
+37 -15
src/applications/herald/field/HeraldField.php
··· 4 4 5 5 private $adapter; 6 6 7 - const STANDARD_LIST = 'standard.list'; 8 7 const STANDARD_BOOL = 'standard.bool'; 9 8 const STANDARD_TEXT = 'standard.text'; 10 9 const STANDARD_TEXT_LIST = 'standard.text.list'; 11 10 const STANDARD_TEXT_MAP = 'standard.text.map'; 12 11 const STANDARD_PHID = 'standard.phid'; 12 + const STANDARD_PHID_LIST = 'standard.phid.list'; 13 13 const STANDARD_PHID_BOOL = 'standard.phid.bool'; 14 14 const STANDARD_PHID_NULLABLE = 'standard.phid.nullable'; 15 15 16 16 abstract public function getHeraldFieldName(); 17 17 abstract public function getHeraldFieldValue($object); 18 18 19 + protected function getHeraldFieldStandardType() { 20 + throw new PhutilMethodNotImplementedException(); 21 + } 22 + 19 23 public function getHeraldFieldConditions() { 20 - switch ($this->getHeraldFieldStandardConditions()) { 21 - case self::STANDARD_LIST: 22 - return array( 23 - HeraldAdapter::CONDITION_INCLUDE_ALL, 24 - HeraldAdapter::CONDITION_INCLUDE_ANY, 25 - HeraldAdapter::CONDITION_INCLUDE_NONE, 26 - HeraldAdapter::CONDITION_EXISTS, 27 - HeraldAdapter::CONDITION_NOT_EXISTS, 28 - ); 24 + $standard_type = $this->getHeraldFieldStandardType(); 25 + switch ($standard_type) { 29 26 case self::STANDARD_BOOL: 30 27 return array( 31 28 HeraldAdapter::CONDITION_IS_TRUE, ··· 44 41 HeraldAdapter::CONDITION_IS_ANY, 45 42 HeraldAdapter::CONDITION_IS_NOT_ANY, 46 43 ); 44 + case self::STANDARD_PHID_LIST: 45 + return array( 46 + HeraldAdapter::CONDITION_INCLUDE_ALL, 47 + HeraldAdapter::CONDITION_INCLUDE_ANY, 48 + HeraldAdapter::CONDITION_INCLUDE_NONE, 49 + HeraldAdapter::CONDITION_EXISTS, 50 + HeraldAdapter::CONDITION_NOT_EXISTS, 51 + ); 47 52 case self::STANDARD_PHID_BOOL: 48 53 return array( 49 54 HeraldAdapter::CONDITION_EXISTS, ··· 69 74 ); 70 75 } 71 76 72 - throw new Exception(pht('Unknown standard condition set.')); 77 + throw new Exception( 78 + pht( 79 + 'Herald field "%s" has unknown standard type "%s".', 80 + get_class($this), 81 + $standard_type)); 73 82 } 74 83 75 - protected function getHeraldFieldStandardConditions() { 76 - throw new PhutilMethodNotImplementedException(); 77 - } 84 + public function getHeraldFieldValueType($condition) { 85 + $standard_type = $this->getHeraldFieldStandardType(); 86 + switch ($standard_type) { 87 + case self::STANDARD_BOOL: 88 + case self::STANDARD_PHID_BOOL: 89 + return HeraldAdapter::VALUE_NONE; 90 + case self::STANDARD_TEXT: 91 + case self::STANDARD_TEXT_LIST: 92 + case self::STANDARD_TEXT_MAP: 93 + return HeraldAdapter::VALUE_TEXT; 94 + } 78 95 79 - abstract public function getHeraldFieldValueType($condition); 96 + throw new Exception( 97 + pht( 98 + 'Herald field "%s" has unknown standard type "%s".', 99 + get_class($this), 100 + $standard_type)); 101 + } 80 102 81 103 abstract public function supportsObject($object); 82 104
+1 -5
src/applications/herald/field/HeraldNewObjectField.php
··· 16 16 return $this->getAdapter()->getIsNewObject(); 17 17 } 18 18 19 - protected function getHeraldFieldStandardConditions() { 19 + protected function getHeraldFieldStandardType() { 20 20 return self::STANDARD_BOOL; 21 - } 22 - 23 - public function getHeraldFieldValueType($condition) { 24 - return HeraldAdapter::VALUE_NONE; 25 21 } 26 22 27 23 }
+1 -1
src/applications/maniphest/herald/ManiphestTaskAssigneeHeraldField.php
··· 13 13 return $object->getOwnerPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19
+1 -1
src/applications/maniphest/herald/ManiphestTaskAuthorHeraldField.php
··· 13 13 return $object->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+1 -5
src/applications/maniphest/herald/ManiphestTaskDescriptionHeraldField.php
··· 13 13 return $object->getDescription(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/maniphest/herald/ManiphestTaskPriorityHeraldField.php
··· 13 13 return $object->getPriority(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+1 -1
src/applications/maniphest/herald/ManiphestTaskStatusHeraldField.php
··· 13 13 return $object->getStatus(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+1 -5
src/applications/maniphest/herald/ManiphestTaskTitleHeraldField.php
··· 13 13 return $object->getTitle(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+2 -2
src/applications/metamta/herald/PhabricatorMetaMTAApplicationEmailHeraldField.php
··· 24 24 return $phids; 25 25 } 26 26 27 - protected function getHeraldFieldStandardConditions() { 28 - return self::STANDARD_LIST; 27 + protected function getHeraldFieldStandardType() { 28 + return self::STANDARD_PHID_LIST; 29 29 } 30 30 31 31 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/pholio/herald/PholioMockAuthorHeraldField.php
··· 13 13 return $object->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+1 -5
src/applications/pholio/herald/PholioMockDescriptionHeraldField.php
··· 13 13 return $object->getDescription(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/pholio/herald/PholioMockNameHeraldField.php
··· 13 13 return $object->getName(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -1
src/applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php
··· 13 13 return $object->getContent()->getAuthorPHID(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_PHID; 18 18 } 19 19
+1 -5
src/applications/phriction/herald/PhrictionDocumentContentHeraldField.php
··· 13 13 return $object->getContent()->getContent(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/phriction/herald/PhrictionDocumentPathHeraldField.php
··· 13 13 return $object->getcontent()->getSlug(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+1 -5
src/applications/phriction/herald/PhrictionDocumentTitleHeraldField.php
··· 13 13 return $object->getContent()->getTitle(); 14 14 } 15 15 16 - protected function getHeraldFieldStandardConditions() { 16 + protected function getHeraldFieldStandardType() { 17 17 return self::STANDARD_TEXT; 18 - } 19 - 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TEXT; 22 18 } 23 19 24 20 }
+2 -2
src/applications/project/herald/HeraldProjectsField.php
··· 18 18 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 19 19 } 20 20 21 - protected function getHeraldFieldStandardConditions() { 22 - return self::STANDARD_LIST; 21 + protected function getHeraldFieldStandardType() { 22 + return self::STANDARD_PHID_LIST; 23 23 } 24 24 25 25 public function getHeraldFieldValueType($condition) {
+1 -1
src/applications/spaces/herald/HeraldSpaceField.php
··· 16 16 return PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object); 17 17 } 18 18 19 - protected function getHeraldFieldStandardConditions() { 19 + protected function getHeraldFieldStandardType() { 20 20 return self::STANDARD_PHID; 21 21 } 22 22
+2 -2
src/applications/subscriptions/herald/HeraldSubscribersField.php
··· 17 17 return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); 18 18 } 19 19 20 - protected function getHeraldFieldStandardConditions() { 21 - return self::STANDARD_LIST; 20 + protected function getHeraldFieldStandardType() { 21 + return self::STANDARD_PHID_LIST; 22 22 } 23 23 24 24 public function getHeraldFieldValueType($condition) {