Added "set:" preffix to check the parameter was set
This commit is contained in:
parent
f306f8dd4d
commit
177b6a6804
6
base.php
6
base.php
|
@ -100,6 +100,9 @@ function arg($arg, $default=null, $validator=null) {
|
|||
} else if (strpos($arg,'b64:') === 0) {
|
||||
$type = 'base64';
|
||||
$arg = substr($arg, 4);
|
||||
} else if (strpos($arg,'set:') === 0) {
|
||||
$type = 'exists';
|
||||
$arg = substr($arg, 4);
|
||||
}
|
||||
|
||||
$ps = explode('.', $arg);
|
||||
|
@ -116,6 +119,9 @@ function arg($arg, $default=null, $validator=null) {
|
|||
if ($arr === null)
|
||||
$arr = $ps[0];
|
||||
eval('$value = isset($'.$arr.'["'.$ps[1].'"]) ? $'.$arr.'["'.$ps[1].'"] : null;');
|
||||
|
||||
if ($type === 'exists')
|
||||
return $value !== null;
|
||||
if ($value === null)
|
||||
return !$require ? $default : apiresult(['error' => '<'.$arg.'> parameter must be specified'], 400);
|
||||
|
||||
|
|
Loading…
Reference in New Issue