Translated using Weblate (Slovenian)
[phpmyadmin.git] / src / Controllers / Normalization / AddNewPrimaryController.php
blob930e250f06b0304ce47dcbafc2b00734499a1b70
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Controllers\Normalization;
7 use PhpMyAdmin\Controllers\AbstractController;
8 use PhpMyAdmin\Http\ServerRequest;
9 use PhpMyAdmin\Identifiers\DatabaseName;
10 use PhpMyAdmin\Identifiers\TableName;
11 use PhpMyAdmin\Normalization;
12 use PhpMyAdmin\ResponseRenderer;
13 use PhpMyAdmin\Template;
14 use PhpMyAdmin\Url;
16 final class AddNewPrimaryController extends AbstractController
18 public function __construct(ResponseRenderer $response, Template $template, private Normalization $normalization)
20 parent::__construct($response, $template);
23 public function __invoke(ServerRequest $request): void
25 $numFields = 1;
27 $db = DatabaseName::tryFrom($GLOBALS['db']);
28 $table = TableName::tryFrom($GLOBALS['table']);
29 $dbName = isset($db) ? $db->getName() : '';
30 $tableName = isset($table) ? $table->getName() : '';
32 $columnMeta = ['Field' => $tableName . '_id', 'Extra' => 'auto_increment'];
33 $html = $this->normalization->getHtmlForCreateNewColumn($numFields, $dbName, $tableName, $columnMeta);
34 $html .= Url::getHiddenInputs($dbName, $tableName);
35 $this->response->addHTML($html);