phpmyadmin/src/Controllers/Server/ShowEngineController.php
Kamil Tekiela ce016798f9 Remove all unnecessary $GLOBALS['errorUrl']
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2024-12-12 23:05:34 +00:00

67 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;
use PhpMyAdmin\Controllers\InvocableController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\StorageEngine;
use function is_array;
use function is_string;
/**
* Displays details about a given Storage Engine.
*/
final class ShowEngineController implements InvocableController
{
private string $engine = '';
private string $page = '';
public function __construct(private readonly ResponseRenderer $response, private readonly DatabaseInterface $dbi)
{
}
public function __invoke(ServerRequest $request): Response
{
$this->setEngineAndPageProperties($request->getAttribute('routeVars'));
if ($this->dbi->isSuperUser()) {
$this->dbi->selectDb('mysql');
}
$engine = [];
if (StorageEngine::isValid($this->engine)) {
$storageEngine = StorageEngine::getEngine($this->engine);
$engine = [
'engine' => $this->engine,
'title' => $storageEngine->getTitle(),
'help_page' => $storageEngine->getMysqlHelpPage(),
'comment' => $storageEngine->getComment(),
'info_pages' => $storageEngine->getInfoPages(),
'support' => $storageEngine->getSupportInformationMessage(),
'variables' => $storageEngine->getHtmlVariables(),
'page' => $this->page !== '' ? $storageEngine->getPage($this->page) : '',
];
}
$this->response->render('server/engines/show', ['engine' => $engine, 'page' => $this->page]);
return $this->response->response();
}
private function setEngineAndPageProperties(mixed $routeVars): void
{
if (! is_array($routeVars)) {
return;
}
$this->engine = isset($routeVars['engine']) && is_string($routeVars['engine']) ? $routeVars['engine'] : '';
$this->page = isset($routeVars['page']) && is_string($routeVars['page']) ? $routeVars['page'] : '';
}
}