phpmyadmin/libraries/classes/Controllers/Normalization/AddNewPrimaryController.php
Maurício Meneghini Fauth c550d41d1d
Extract normalization's add new primary action
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-08-02 16:45:30 -03:00

42 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Normalization;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Normalization;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
final class AddNewPrimaryController extends AbstractController
{
/** @var Normalization */
private $normalization;
public function __construct(ResponseRenderer $response, Template $template, Normalization $normalization)
{
parent::__construct($response, $template);
$this->normalization = $normalization;
}
public function __invoke(ServerRequest $request): void
{
$num_fields = 1;
$columnMeta = [
'Field' => $GLOBALS['table'] . '_id',
'Extra' => 'auto_increment',
];
$html = $this->normalization->getHtmlForCreateNewColumn(
$num_fields,
$GLOBALS['db'],
$GLOBALS['table'],
$columnMeta
);
$html .= Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
$this->response->addHTML($html);
}
}