mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-27 12:01:09 +03:00
705b9daa0b
The bridge factory can be based on the abstract factory class if it wasn't static. This allows for higher abstraction and makes future extensions possible. Also, not all parts of RSS-Bridge need to work on the same instance of the bridge factory. References #1001
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
|
* Atom feeds for websites that don't have one.
|
|
*
|
|
* For the full license information, please view the UNLICENSE file distributed
|
|
* with this source code.
|
|
*
|
|
* @package Core
|
|
* @license http://unlicense.org/ UNLICENSE
|
|
* @link https://github.com/rss-bridge/rss-bridge
|
|
*/
|
|
|
|
class ListAction extends ActionAbstract {
|
|
public function execute() {
|
|
$list = new StdClass();
|
|
$list->bridges = array();
|
|
$list->total = 0;
|
|
|
|
$bridgeFac = new \BridgeFactory();
|
|
$bridgeFac->setWorkingDir(PATH_LIB_BRIDGES);
|
|
|
|
foreach($bridgeFac->getBridgeNames() as $bridgeName) {
|
|
|
|
$bridge = $bridgeFac->create($bridgeName);
|
|
|
|
if($bridge === false) { // Broken bridge, show as inactive
|
|
|
|
$list->bridges[$bridgeName] = array(
|
|
'status' => 'inactive'
|
|
);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$status = $bridgeFac->isWhitelisted($bridgeName) ? 'active' : 'inactive';
|
|
|
|
$list->bridges[$bridgeName] = array(
|
|
'status' => $status,
|
|
'uri' => $bridge->getURI(),
|
|
'name' => $bridge->getName(),
|
|
'icon' => $bridge->getIcon(),
|
|
'parameters' => $bridge->getParameters(),
|
|
'maintainer' => $bridge->getMaintainer(),
|
|
'description' => $bridge->getDescription()
|
|
);
|
|
|
|
}
|
|
|
|
$list->total = count($list->bridges);
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($list, JSON_PRETTY_PRINT);
|
|
}
|
|
}
|