1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

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
This commit is contained in:
epriestley 2013-08-02 12:03:54 -07:00
parent 9c637604a2
commit 78eb81ffd0
12 changed files with 23 additions and 35 deletions

View file

@ -54,7 +54,6 @@ abstract class HeraldAdapter {
abstract public function getPHID();
abstract public function getHeraldName();
abstract public function getHeraldTypeName();
abstract public function getHeraldField($field_name);
abstract public function applyHeraldEffects(array $effects);
@ -367,6 +366,20 @@ abstract class HeraldAdapter {
$content_type));
}
public static function getEnabledAdapterMap() {
$map = array();
$adapters = HeraldAdapter::getAllEnabledAdapters();
foreach ($adapters as $adapter) {
$type = $adapter->getAdapterContentType();
$name = $adapter->getAdapterContentName();
$map[$type] = $name;
}
asort($map);
return $map;
}
}

View file

@ -149,10 +149,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
$this->commit->getCommitIdentifier();
}
public function getHeraldTypeName() {
return HeraldContentTypeConfig::CONTENT_TYPE_COMMIT;
}
public function loadAffectedPaths() {
if ($this->affectedPaths === null) {
$result = PhabricatorOwnerPathQuery::loadAffectedPaths(

View file

@ -95,10 +95,6 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
return $this->revision->getTitle();
}
public function getHeraldTypeName() {
return HeraldContentTypeConfig::CONTENT_TYPE_DIFFERENTIAL;
}
public function loadRepository() {
if ($this->repository === null) {
$diff = $this->diff;

View file

@ -18,10 +18,6 @@ final class HeraldDryRunAdapter extends HeraldAdapter {
return 'Dry Run';
}
public function getHeraldTypeName() {
return null;
}
public function getHeraldField($field) {
return null;
}

View file

@ -5,17 +5,4 @@ final class HeraldContentTypeConfig {
const CONTENT_TYPE_DIFFERENTIAL = 'differential';
const CONTENT_TYPE_COMMIT = 'commit';
public static function getContentTypeMap() {
$map = array();
$adapters = HeraldAdapter::getAllEnabledAdapters();
foreach ($adapters as $adapter) {
$type = $adapter->getAdapterContentType();
$name = $adapter->getAdapterContentName();
$map[$type] = $name;
}
asort($map);
return $map;
}
}

View file

@ -15,7 +15,7 @@ final class HeraldNewController extends HeraldController {
$request = $this->getRequest();
$user = $request->getUser();
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
if (empty($content_type_map[$this->contentType])) {
$this->contentType = head_key($content_type_map);
}

View file

@ -14,7 +14,7 @@ final class HeraldRuleController extends HeraldController {
$request = $this->getRequest();
$user = $request->getUser();
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
$rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap();
if ($this->id) {

View file

@ -33,7 +33,7 @@ final class HeraldRuleListController extends HeraldController
$phids = mpull($rules, 'getAuthorPHID');
$this->loadHandles($phids);
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
$list = id(new PhabricatorObjectItemListView())
->setUser($viewer);

View file

@ -69,7 +69,7 @@ final class HeraldTestConsoleController extends HeraldController {
}
$rules = HeraldRule::loadAllByContentTypeWithFullData(
$adapter->getHeraldTypeName(),
$adapter->getAdapterContentType(),
$object->getPHID());
$engine = new HeraldEngine();

View file

@ -11,7 +11,7 @@ final class HeraldEngine {
protected $object = null;
public static function loadAndApplyRules(HeraldAdapter $object) {
$content_type = $object->getHeraldTypeName();
$content_type = $object->getAdapterContentType();
$rules = HeraldRule::loadAllByContentTypeWithFullData(
$content_type,
$object->getPHID());
@ -90,7 +90,7 @@ final class HeraldEngine {
$object_transcript = new HeraldObjectTranscript();
$object_transcript->setPHID($object->getPHID());
$object_transcript->setName($object->getHeraldName());
$object_transcript->setType($object->getHeraldTypeName());
$object_transcript->setType($object->getAdapterContentType());
$object_transcript->setFields($this->fieldCache);
$this->transcript->setObjectTranscript($object_transcript);

View file

@ -109,11 +109,11 @@ final class HeraldRuleSearchEngine
private function getContentTypeOptions() {
return array(
'' => pht('(All Content Types)'),
) + HeraldContentTypeConfig::getContentTypeMap();
) + HeraldAdapter::getEnabledAdapterMap();
}
private function getContentTypeValues() {
return array_fuse(array_keys(HeraldContentTypeConfig::getContentTypeMap()));
return array_fuse(array_keys(HeraldAdapter::getEnabledAdapterMap()));
}
private function getRuleTypeOptions() {

View file

@ -22,7 +22,7 @@ final class PhabricatorRepositoryCommitHeraldWorker
}
$rules = HeraldRule::loadAllByContentTypeWithFullData(
HeraldContentTypeConfig::CONTENT_TYPE_COMMIT,
id(new HeraldCommitAdapter())->getAdapterContentType(),
$commit->getPHID());
$adapter = HeraldCommitAdapter::newLegacyAdapter(