[CORE][Controller] Make Controller->{int,bool,string} functions return null if the GET parameter doesn't exist

This commit is contained in:
Hugo Sales 2022-01-01 20:03:40 +00:00
parent fc76a00908
commit acc84d757c
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -236,11 +236,11 @@ abstract class Controller extends AbstractController implements EventSubscriberI
{ {
switch ($method) { switch ($method) {
case 'int': case 'int':
return $this->request->query->getInt($args[0]); return !$this->request->query->has($args[0]) ? null : $this->request->query->getInt($args[0]);
case 'bool': case 'bool':
return $this->request->query->getBoolean($args[0]); return !$this->request->query->has($args[0]) ? null : $this->request->query->getBoolean($args[0]);
case 'string': case 'string':
return $this->request->query->get($args[0]); return !$this->request->query->has($args[0]) ? null : $this->request->query->get($args[0]);
case 'params': case 'params':
return $this->request->query->all(); return $this->request->query->all();
default: default: