phpmyadmin/libraries/classes/Controllers/Normalization/AddNewPrimaryController.php
Maurício Meneghini Fauth 1be42d13de
Create the Identifiers\Identifier interface
Changes Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to
implements the new Identifier\Identifier interface.
Moves Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to the
Identifiers namespace.
Renames the tryFromValue() and fromValue() methods to just tryFrom() and
from() respectively.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-06-01 19:09:25 -03:00

38 lines
1.2 KiB
PHP

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