1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-23 18:29:15 +03:00
Files
phpmyadmin/src/Controllers/Navigation/UpdateNavWidthConfigController.php
Maurício Meneghini Fauth 137283f909 Remove unused constructor params from controllers
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2024-04-08 15:59:34 -03:00

44 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Navigation;
use PhpMyAdmin\Config;
use PhpMyAdmin\Controllers\InvocableController;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\ResponseRenderer;
use function __;
use function is_numeric;
final class UpdateNavWidthConfigController implements InvocableController
{
public function __construct(private readonly ResponseRenderer $response, private readonly Config $config)
{
}
public function __invoke(ServerRequest $request): Response|null
{
$value = $request->getParsedBodyParam('value');
if (! is_numeric($value) || $value < 0) {
$this->response->setRequestStatus(false);
$this->response->addJSON(['message' => Message::error(__('Unexpected parameter value.'))]);
return null;
}
$result = $this->config->setUserValue(null, 'NavigationWidth', (int) $value);
if ($result === true) {
return null;
}
$this->response->setRequestStatus(false);
$this->response->addJSON(['message' => $result]);
return null;
}
}