aowow/endpoints/locale/locale.php
Sarjuuk 05f5b0ed34 Response/Params
* so we can't directly use BackedEnum::tryFrom as validator, because if
   the Enum is of <int> and the string is not what php considers numeric,
   we get a straight TypeError Exception instead of null for failing the tryFrom.
2025-10-06 17:06:49 +02:00

27 lines
552 B
PHP

<?php
namespace Aowow;
if (!defined('AOWOW_REVISION'))
die('illegal access');
class LocaleBaseResponse extends TextResponse
{
protected array $expectedGET = array(
'locale' => ['filter' => FILTER_CALLBACK, 'options' => [self::class, 'checkLocale']]
);
protected function generate() : void
{
if ($this->_get['locale']?->validate())
{
User::$preferedLoc = $this->_get['locale'];
User::save(true);
}
$this->redirectTo = $_SERVER['HTTP_REFERER'] ?? '.';
}
}
?>