mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01: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:
parent
9c637604a2
commit
78eb81ffd0
12 changed files with 23 additions and 35 deletions
|
@ -54,7 +54,6 @@ abstract class HeraldAdapter {
|
||||||
|
|
||||||
abstract public function getPHID();
|
abstract public function getPHID();
|
||||||
abstract public function getHeraldName();
|
abstract public function getHeraldName();
|
||||||
abstract public function getHeraldTypeName();
|
|
||||||
abstract public function getHeraldField($field_name);
|
abstract public function getHeraldField($field_name);
|
||||||
abstract public function applyHeraldEffects(array $effects);
|
abstract public function applyHeraldEffects(array $effects);
|
||||||
|
|
||||||
|
@ -367,6 +366,20 @@ abstract class HeraldAdapter {
|
||||||
$content_type));
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,10 +149,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
||||||
$this->commit->getCommitIdentifier();
|
$this->commit->getCommitIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeraldTypeName() {
|
|
||||||
return HeraldContentTypeConfig::CONTENT_TYPE_COMMIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadAffectedPaths() {
|
public function loadAffectedPaths() {
|
||||||
if ($this->affectedPaths === null) {
|
if ($this->affectedPaths === null) {
|
||||||
$result = PhabricatorOwnerPathQuery::loadAffectedPaths(
|
$result = PhabricatorOwnerPathQuery::loadAffectedPaths(
|
||||||
|
|
|
@ -95,10 +95,6 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
|
||||||
return $this->revision->getTitle();
|
return $this->revision->getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeraldTypeName() {
|
|
||||||
return HeraldContentTypeConfig::CONTENT_TYPE_DIFFERENTIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadRepository() {
|
public function loadRepository() {
|
||||||
if ($this->repository === null) {
|
if ($this->repository === null) {
|
||||||
$diff = $this->diff;
|
$diff = $this->diff;
|
||||||
|
|
|
@ -18,10 +18,6 @@ final class HeraldDryRunAdapter extends HeraldAdapter {
|
||||||
return 'Dry Run';
|
return 'Dry Run';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeraldTypeName() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeraldField($field) {
|
public function getHeraldField($field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,4 @@ final class HeraldContentTypeConfig {
|
||||||
const CONTENT_TYPE_DIFFERENTIAL = 'differential';
|
const CONTENT_TYPE_DIFFERENTIAL = 'differential';
|
||||||
const CONTENT_TYPE_COMMIT = 'commit';
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class HeraldNewController extends HeraldController {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
|
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
|
||||||
if (empty($content_type_map[$this->contentType])) {
|
if (empty($content_type_map[$this->contentType])) {
|
||||||
$this->contentType = head_key($content_type_map);
|
$this->contentType = head_key($content_type_map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class HeraldRuleController extends HeraldController {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
|
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
|
||||||
$rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap();
|
$rule_type_map = HeraldRuleTypeConfig::getRuleTypeMap();
|
||||||
|
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ final class HeraldRuleListController extends HeraldController
|
||||||
$phids = mpull($rules, 'getAuthorPHID');
|
$phids = mpull($rules, 'getAuthorPHID');
|
||||||
$this->loadHandles($phids);
|
$this->loadHandles($phids);
|
||||||
|
|
||||||
$content_type_map = HeraldContentTypeConfig::getContentTypeMap();
|
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
|
||||||
|
|
||||||
$list = id(new PhabricatorObjectItemListView())
|
$list = id(new PhabricatorObjectItemListView())
|
||||||
->setUser($viewer);
|
->setUser($viewer);
|
||||||
|
|
|
@ -69,7 +69,7 @@ final class HeraldTestConsoleController extends HeraldController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
||||||
$adapter->getHeraldTypeName(),
|
$adapter->getAdapterContentType(),
|
||||||
$object->getPHID());
|
$object->getPHID());
|
||||||
|
|
||||||
$engine = new HeraldEngine();
|
$engine = new HeraldEngine();
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class HeraldEngine {
|
||||||
protected $object = null;
|
protected $object = null;
|
||||||
|
|
||||||
public static function loadAndApplyRules(HeraldAdapter $object) {
|
public static function loadAndApplyRules(HeraldAdapter $object) {
|
||||||
$content_type = $object->getHeraldTypeName();
|
$content_type = $object->getAdapterContentType();
|
||||||
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
||||||
$content_type,
|
$content_type,
|
||||||
$object->getPHID());
|
$object->getPHID());
|
||||||
|
@ -90,7 +90,7 @@ final class HeraldEngine {
|
||||||
$object_transcript = new HeraldObjectTranscript();
|
$object_transcript = new HeraldObjectTranscript();
|
||||||
$object_transcript->setPHID($object->getPHID());
|
$object_transcript->setPHID($object->getPHID());
|
||||||
$object_transcript->setName($object->getHeraldName());
|
$object_transcript->setName($object->getHeraldName());
|
||||||
$object_transcript->setType($object->getHeraldTypeName());
|
$object_transcript->setType($object->getAdapterContentType());
|
||||||
$object_transcript->setFields($this->fieldCache);
|
$object_transcript->setFields($this->fieldCache);
|
||||||
|
|
||||||
$this->transcript->setObjectTranscript($object_transcript);
|
$this->transcript->setObjectTranscript($object_transcript);
|
||||||
|
|
|
@ -109,11 +109,11 @@ final class HeraldRuleSearchEngine
|
||||||
private function getContentTypeOptions() {
|
private function getContentTypeOptions() {
|
||||||
return array(
|
return array(
|
||||||
'' => pht('(All Content Types)'),
|
'' => pht('(All Content Types)'),
|
||||||
) + HeraldContentTypeConfig::getContentTypeMap();
|
) + HeraldAdapter::getEnabledAdapterMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getContentTypeValues() {
|
private function getContentTypeValues() {
|
||||||
return array_fuse(array_keys(HeraldContentTypeConfig::getContentTypeMap()));
|
return array_fuse(array_keys(HeraldAdapter::getEnabledAdapterMap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRuleTypeOptions() {
|
private function getRuleTypeOptions() {
|
||||||
|
|
|
@ -22,7 +22,7 @@ final class PhabricatorRepositoryCommitHeraldWorker
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
$rules = HeraldRule::loadAllByContentTypeWithFullData(
|
||||||
HeraldContentTypeConfig::CONTENT_TYPE_COMMIT,
|
id(new HeraldCommitAdapter())->getAdapterContentType(),
|
||||||
$commit->getPHID());
|
$commit->getPHID());
|
||||||
|
|
||||||
$adapter = HeraldCommitAdapter::newLegacyAdapter(
|
$adapter = HeraldCommitAdapter::newLegacyAdapter(
|
||||||
|
|
Loading…
Reference in a new issue