-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathThemesController.php
More file actions
38 lines (30 loc) · 995 Bytes
/
ThemesController.php
File metadata and controls
38 lines (30 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\Template;
use PhpMyAdmin\Theme\ThemeManager;
#[Route('/themes', ['GET'])]
final readonly class ThemesController implements InvocableController
{
public function __construct(
private ResponseRenderer $response,
private Template $template,
private ThemeManager $themeManager,
) {
}
public function __invoke(ServerRequest $request): Response
{
$themes = $this->themeManager->getThemesArray();
$themesList = $this->template->render('home/themes', ['themes' => $themes]);
if ($request->isAjax()) {
$this->response->addJSON('themes', $themesList);
return $this->response->response();
}
$this->response->addHTML($themesList);
return $this->response->response();
}
}