phpmyadmin/libraries/classes/Controllers/ThemesController.php
Maurício Meneghini Fauth 19dad3b153
Add a isAjax() method to ServerRequest class
This method belongs to the ServerRequest class instead of the
ResponseRenderer class, as it's a request property.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-07-26 16:01:37 -03:00

32 lines
818 B
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
use PhpMyAdmin\Theme\ThemeManager;
class ThemesController extends AbstractController
{
public function __construct(ResponseRenderer $response, Template $template, private ThemeManager $themeManager)
{
parent::__construct($response, $template);
}
public function __invoke(ServerRequest $request): void
{
$themes = $this->themeManager->getThemesArray();
$themesList = $this->template->render('home/themes', ['themes' => $themes]);
if ($request->isAjax()) {
$this->response->addJSON('themes', $themesList);
return;
}
$this->response->addHTML($themesList);
}
}