This commit is contained in:
Dag 2024-08-07 00:21:06 +02:00 committed by GitHub
parent 401cc187b7
commit 6ec9193546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 12 additions and 18 deletions

View File

@ -19,7 +19,7 @@ class ConnectivityAction implements ActionInterface
$this->bridgeFactory = new BridgeFactory();
}
public function execute(Request $request)
public function __invoke(Request $request): Response
{
if (!Debug::isEnabled()) {
return new Response('This action is only available in debug mode!', 403);
@ -27,7 +27,7 @@ class ConnectivityAction implements ActionInterface
$bridgeName = $request->get('bridge');
if (!$bridgeName) {
return render_template('connectivity.html.php');
return new Response(render_template('connectivity.html.php'));
}
$bridgeClassName = $this->bridgeFactory->createBridgeClassName($bridgeName);
if (!$bridgeClassName) {

View File

@ -2,7 +2,7 @@
class DetectAction implements ActionInterface
{
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$url = $request->get('url');
$format = $request->get('format');

View File

@ -11,7 +11,7 @@ class DisplayAction implements ActionInterface
$this->logger = RssBridge::getLogger();
}
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$bridgeName = $request->get('bridge');
$format = $request->get('format');

View File

@ -7,7 +7,7 @@
*/
class FindfeedAction implements ActionInterface
{
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$url = $request->get('url');
$format = $request->get('format');

View File

@ -2,7 +2,7 @@
final class FrontpageAction implements ActionInterface
{
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$messages = [];
$activeBridges = 0;
@ -26,13 +26,13 @@ final class FrontpageAction implements ActionInterface
}
// todo: cache this renderered template?
return render(__DIR__ . '/../templates/frontpage.html.php', [
return new Response(render(__DIR__ . '/../templates/frontpage.html.php', [
'messages' => $messages,
'admin_email' => Configuration::getConfig('admin', 'email'),
'admin_telegram' => Configuration::getConfig('admin', 'telegram'),
'bridges' => $body,
'active_bridges' => $activeBridges,
'total_bridges' => count($bridgeClassNames),
]);
]));
}
}

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
class HealthAction implements ActionInterface
{
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$response = [
'code' => 200,

View File

@ -2,7 +2,7 @@
class ListAction implements ActionInterface
{
public function execute(Request $request)
public function __invoke(Request $request): Response
{
$list = new \stdClass();
$list->bridges = [];

View File

@ -2,8 +2,5 @@
interface ActionInterface
{
/**
* @return string|Response
*/
public function execute(Request $request);
public function __invoke(Request $request): Response;
}

View File

@ -100,11 +100,8 @@ final class RssBridge
$className = '\\' . $actionName;
$actionObject = new $className();
$response = $actionObject->execute($request);
$response = $actionObject($request);
if (is_string($response)) {
$response = new Response($response);
}
return $response;
}