2019-02-06 20:34:51 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-22 19:30:37 +03:00
|
|
|
class ListAction implements ActionInterface
|
|
|
|
{
|
2024-08-29 23:48:59 +03:00
|
|
|
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
|
|
|
{
|
2022-08-06 23:46:28 +03:00
|
|
|
$list = new \stdClass();
|
2019-02-06 20:34:51 +03:00
|
|
|
$list->bridges = [];
|
|
|
|
$list->total = 0;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2024-08-29 23:48:59 +03:00
|
|
|
foreach ($this->bridgeFactory->getBridgeClassNames() as $bridgeClassName) {
|
|
|
|
$bridge = $this->bridgeFactory->create($bridgeClassName);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-07-08 13:54:23 +03:00
|
|
|
$list->bridges[$bridgeClassName] = [
|
2024-08-29 23:48:59 +03:00
|
|
|
'status' => $this->bridgeFactory->isEnabled($bridgeClassName) ? 'active' : 'inactive',
|
2023-10-01 20:23:30 +03:00
|
|
|
'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);
|
2023-09-10 22:50:15 +03:00
|
|
|
return new Response(Json::encode($list), 200, ['content-type' => 'application/json']);
|
2019-02-06 20:34:51 +03:00
|
|
|
}
|
|
|
|
}
|