phpmyadmin/libraries/classes/Controllers/SchemaExportController.php
Kamil Tekiela 959849f446
Introduce ServerRequest::hasBodyParam() (#17870)
* Drop Sql::setUiProp()
* Remove ternary operator
* Improve array guard
* Remove redundant isset
* Implement hasBodyParam()
* Add has() and hasQueryParam()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2022-11-05 13:04:45 -03:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Export;
use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\ResponseRenderer;
use RuntimeException;
use function __;
/**
* Schema export handler
*/
class SchemaExportController
{
/** @var Export */
private $export;
/** @var ResponseRenderer */
private $response;
public function __construct(Export $export, ResponseRenderer $response)
{
$this->export = $export;
$this->response = $response;
}
public function __invoke(ServerRequest $request): void
{
if (! $request->hasBodyParam('export_type')) {
$errorMessage = __('Missing parameter:') . ' export_type'
. MySQLDocumentation::showDocumentation('faq', 'faqmissingparameters', true)
. '[br]';
$this->response->setRequestStatus(false);
$this->response->addHTML(Message::error($errorMessage)->getDisplay());
return;
}
/**
* Include the appropriate Schema Class depending on $export_type
* default is PDF
*/
try {
$this->export->processExportSchema($request->getParsedBodyParam('export_type'));
} catch (RuntimeException $exception) {
$this->response->setRequestStatus(false);
$this->response->addHTML(Message::error($exception->getMessage())->getDisplay());
}
}
}