rss-bridge/actions/ListAction.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.4 KiB
PHP
Raw Normal View History

2019-02-06 20:34:51 +03:00
<?php
2019-02-06 20:34:51 +03:00
/**
* 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
*/
2022-06-22 19:30:37 +03:00
class ListAction implements ActionInterface
{
public function execute(array $request)
2019-02-06 20:34:51 +03:00
{
$list = new \stdClass();
2019-02-06 20:34:51 +03:00
$list->bridges = [];
$list->total = 0;
$bridgeFactory = new BridgeFactory();
foreach ($bridgeFactory->getBridgeClassNames() as $bridgeClassName) {
$bridge = $bridgeFactory->create($bridgeClassName);
$list->bridges[$bridgeClassName] = [
'status' => $bridgeFactory->isEnabled($bridgeClassName) ? 'active' : 'inactive',
2019-02-06 20:34:51 +03:00
'uri' => $bridge->getURI(),
'donationUri' => $bridge->getDonationURI(),
2019-02-06 20:34:51 +03:00
'name' => $bridge->getName(),
'icon' => $bridge->getIcon(),
'parameters' => $bridge->getParameters(),
'maintainer' => $bridge->getMaintainer(),
'description' => $bridge->getDescription()
];
}
$list->total = count($list->bridges);
return new Response(Json::encode($list), 200, ['Content-Type' => 'application/json']);
2019-02-06 20:34:51 +03:00
}
}