-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathTableController.php
More file actions
34 lines (26 loc) · 941 Bytes
/
TableController.php
File metadata and controls
34 lines (26 loc) · 941 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
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
#[Route('/tables', ['POST'])]
final readonly class TableController implements InvocableController
{
public function __construct(private ResponseRenderer $response, private DatabaseInterface $dbi)
{
}
public function __invoke(ServerRequest $request): Response
{
if (! $request->hasBodyParam('db')) {
$this->response->setRequestStatus(false);
$this->response->addJSON(['message' => Message::error()]);
return $this->response->response();
}
$this->response->addJSON(['tables' => $this->dbi->getTables($request->getParsedBodyParamAsString('db'))]);
return $this->response->response();
}
}