mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-10 10:34:15 +02:00
refactor(BridgeFactory): make methods only accept valid class names (#2897)
This moves the responsibility for getting a valid class name to the users of BridgeFactory, avoiding the repeated sanitation. Improper use can also be checked statically.
This commit is contained in:
@@ -22,20 +22,20 @@ class ListAction implements ActionInterface
|
||||
|
||||
$bridgeFactory = new \BridgeFactory();
|
||||
|
||||
foreach ($bridgeFactory->getBridgeNames() as $bridgeName) {
|
||||
$bridge = $bridgeFactory->create($bridgeName);
|
||||
foreach ($bridgeFactory->getBridgeClassNames() as $bridgeClassName) {
|
||||
$bridge = $bridgeFactory->create($bridgeClassName);
|
||||
|
||||
if ($bridge === false) { // Broken bridge, show as inactive
|
||||
$list->bridges[$bridgeName] = [
|
||||
$list->bridges[$bridgeClassName] = [
|
||||
'status' => 'inactive'
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = $bridgeFactory->isWhitelisted($bridgeName) ? 'active' : 'inactive';
|
||||
$status = $bridgeFactory->isWhitelisted($bridgeClassName) ? 'active' : 'inactive';
|
||||
|
||||
$list->bridges[$bridgeName] = [
|
||||
$list->bridges[$bridgeClassName] = [
|
||||
'status' => $status,
|
||||
'uri' => $bridge->getURI(),
|
||||
'donationUri' => $bridge->getDonationURI(),
|
||||
|
Reference in New Issue
Block a user