* 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.
27 lines
552 B
PHP
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'] ?? '.';
|
|
}
|
|
}
|
|
|
|
?>
|