rss-bridge/actions/ListAction.php

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

37 lines
1.2 KiB
PHP
Raw Normal View History

2019-02-06 20:34:51 +03:00
<?php
2022-06-22 19:30:37 +03:00
class ListAction implements ActionInterface
{
private BridgeFactory $bridgeFactory;
public function __construct(
BridgeFactory $bridgeFactory
) {
$this->bridgeFactory = $bridgeFactory;
}
2024-08-07 01:21:06 +03:00
public function __invoke(Request $request): Response
2019-02-06 20:34:51 +03:00
{
$list = new \stdClass();
2019-02-06 20:34:51 +03:00
$list->bridges = [];
$list->total = 0;
foreach ($this->bridgeFactory->getBridgeClassNames() as $bridgeClassName) {
$bridge = $this->bridgeFactory->create($bridgeClassName);
$list->bridges[$bridgeClassName] = [
'status' => $this->bridgeFactory->isEnabled($bridgeClassName) ? 'active' : 'inactive',
'uri' => $bridge->getURI(),
'donationUri' => $bridge->getDonationURI(),
'name' => $bridge->getName(),
'icon' => $bridge->getIcon(),
'parameters' => $bridge->getParameters(),
'maintainer' => $bridge->getMaintainer(),
'description' => $bridge->getDescription()
2019-02-06 20:34:51 +03:00
];
}
$list->total = count($list->bridges);
return new Response(Json::encode($list), 200, ['content-type' => 'application/json']);
2019-02-06 20:34:51 +03:00
}
}