Case-insensitive parameter in presenter method
- materix
- Backer | 83
This works in the router
public static function createRouter(): RouteList
{
$router = new RouteList;
$router->addRoute('?<ID|id>=<ID>', 'Home:default');
return $router;
}
But how to make parameter case-insensitive in the presenter-methods?
function renderDefault(?string $id): void
{}
or
function renderDefault(?string $ID): void
{}
so that parameter can be both $id
and $ID
?
- Lumeriol
- Generous Backer | 63
It is not possible. In PHP variable names are case sensitive, so $id and $ID or $Id are three different variables.
I recommend you to use PHP standards, you will have an easier life and coding :)
- Šaman
- Member | 2659
You can (probably, I never used it in presenter methods) take a generic parameter and process it with your own code. Parse, convert to lowercase and try to find the expected parameter.
But it's not best practice and you won't be able to use Nette features.
function renderDefault(mixed $arg): void
{
// $arg may or may not be anything :)
}
Last edited by Šaman (Yesterday 12:10)