@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove almost all instances of HeraldContentTypeConfig

Summary: Ref T2769. This cleans up almost every use of the HeraldContentTypeConfig class.

Test Plan: Viewed and edited Herald rules.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2769

Differential Revision: https://secure.phabricator.com/D6662

+23 -35
+14 -1
src/applications/herald/adapter/HeraldAdapter.php
··· 54 54 55 55 abstract public function getPHID(); 56 56 abstract public function getHeraldName(); 57 - abstract public function getHeraldTypeName(); 58 57 abstract public function getHeraldField($field_name); 59 58 abstract public function applyHeraldEffects(array $effects); 60 59 ··· 365 364 pht( 366 365 'No adapter exists for Herald content type "%s".', 367 366 $content_type)); 367 + } 368 + 369 + public static function getEnabledAdapterMap() { 370 + $map = array(); 371 + 372 + $adapters = HeraldAdapter::getAllEnabledAdapters(); 373 + foreach ($adapters as $adapter) { 374 + $type = $adapter->getAdapterContentType(); 375 + $name = $adapter->getAdapterContentName(); 376 + $map[$type] = $name; 377 + } 378 + 379 + asort($map); 380 + return $map; 368 381 } 369 382 370 383
-4
src/applications/herald/adapter/HeraldCommitAdapter.php
··· 149 149 $this->commit->getCommitIdentifier(); 150 150 } 151 151 152 - public function getHeraldTypeName() { 153 - return HeraldContentTypeConfig::CONTENT_TYPE_COMMIT; 154 - } 155 - 156 152 public function loadAffectedPaths() { 157 153 if ($this->affectedPaths === null) { 158 154 $result = PhabricatorOwnerPathQuery::loadAffectedPaths(
-4
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
··· 95 95 return $this->revision->getTitle(); 96 96 } 97 97 98 - public function getHeraldTypeName() { 99 - return HeraldContentTypeConfig::CONTENT_TYPE_DIFFERENTIAL; 100 - } 101 - 102 98 public function loadRepository() { 103 99 if ($this->repository === null) { 104 100 $diff = $this->diff;
-4
src/applications/herald/adapter/HeraldDryRunAdapter.php
··· 18 18 return 'Dry Run'; 19 19 } 20 20 21 - public function getHeraldTypeName() { 22 - return null; 23 - } 24 - 25 21 public function getHeraldField($field) { 26 22 return null; 27 23 }
-13
src/applications/herald/config/HeraldContentTypeConfig.php
··· 5 5 const CONTENT_TYPE_DIFFERENTIAL = 'differential'; 6 6 const CONTENT_TYPE_COMMIT = 'commit'; 7 7 8 - public static function getContentTypeMap() { 9 - $map = array(); 10 - 11 - $adapters = HeraldAdapter::getAllEnabledAdapters(); 12 - foreach ($adapters as $adapter) { 13 - $type = $adapter->getAdapterContentType(); 14 - $name = $adapter->getAdapterContentName(); 15 - $map[$type] = $name; 16 - } 17 - 18 - asort($map); 19 - return $map; 20 - } 21 8 }
+1 -1
src/applications/herald/controller/HeraldNewController.php
··· 15 15 $request = $this->getRequest(); 16 16 $user = $request->getUser(); 17 17 18 - $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); 18 + $content_type_map = HeraldAdapter::getEnabledAdapterMap(); 19 19 if (empty($content_type_map[$this->contentType])) { 20 20 $this->contentType = head_key($content_type_map); 21 21 }
+1 -1
src/applications/herald/controller/HeraldRuleController.php
··· 14 14 $request = $this->getRequest(); 15 15 $user = $request->getUser(); 16 16 17 - $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); 17 + $content_type_map = HeraldAdapter::getEnabledAdapterMap(); 18 18 $rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap(); 19 19 20 20 if ($this->id) {
+1 -1
src/applications/herald/controller/HeraldRuleListController.php
··· 33 33 $phids = mpull($rules, 'getAuthorPHID'); 34 34 $this->loadHandles($phids); 35 35 36 - $content_type_map = HeraldContentTypeConfig::getContentTypeMap(); 36 + $content_type_map = HeraldAdapter::getEnabledAdapterMap(); 37 37 38 38 $list = id(new PhabricatorObjectItemListView()) 39 39 ->setUser($viewer);
+1 -1
src/applications/herald/controller/HeraldTestConsoleController.php
··· 69 69 } 70 70 71 71 $rules = HeraldRule::loadAllByContentTypeWithFullData( 72 - $adapter->getHeraldTypeName(), 72 + $adapter->getAdapterContentType(), 73 73 $object->getPHID()); 74 74 75 75 $engine = new HeraldEngine();
+2 -2
src/applications/herald/engine/HeraldEngine.php
··· 11 11 protected $object = null; 12 12 13 13 public static function loadAndApplyRules(HeraldAdapter $object) { 14 - $content_type = $object->getHeraldTypeName(); 14 + $content_type = $object->getAdapterContentType(); 15 15 $rules = HeraldRule::loadAllByContentTypeWithFullData( 16 16 $content_type, 17 17 $object->getPHID()); ··· 90 90 $object_transcript = new HeraldObjectTranscript(); 91 91 $object_transcript->setPHID($object->getPHID()); 92 92 $object_transcript->setName($object->getHeraldName()); 93 - $object_transcript->setType($object->getHeraldTypeName()); 93 + $object_transcript->setType($object->getAdapterContentType()); 94 94 $object_transcript->setFields($this->fieldCache); 95 95 96 96 $this->transcript->setObjectTranscript($object_transcript);
+2 -2
src/applications/herald/query/HeraldRuleSearchEngine.php
··· 109 109 private function getContentTypeOptions() { 110 110 return array( 111 111 '' => pht('(All Content Types)'), 112 - ) + HeraldContentTypeConfig::getContentTypeMap(); 112 + ) + HeraldAdapter::getEnabledAdapterMap(); 113 113 } 114 114 115 115 private function getContentTypeValues() { 116 - return array_fuse(array_keys(HeraldContentTypeConfig::getContentTypeMap())); 116 + return array_fuse(array_keys(HeraldAdapter::getEnabledAdapterMap())); 117 117 } 118 118 119 119 private function getRuleTypeOptions() {
+1 -1
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
··· 22 22 } 23 23 24 24 $rules = HeraldRule::loadAllByContentTypeWithFullData( 25 - HeraldContentTypeConfig::CONTENT_TYPE_COMMIT, 25 + id(new HeraldCommitAdapter())->getAdapterContentType(), 26 26 $commit->getPHID()); 27 27 28 28 $adapter = HeraldCommitAdapter::newLegacyAdapter(