added wrapper for boolean api-parameters, Domains-Module for now, more later; fixes #597

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-04 13:27:21 +01:00
parent cf53365007
commit 07d7908f6e
2 changed files with 63 additions and 90 deletions

View File

@@ -79,6 +79,31 @@ abstract class ApiParameter
return $this->cmd_params[$param];
}
/**
* getParam wrapper for boolean parameter
*
* @param string $param
* parameter to get out of the request-parameter list
* @param bool $optional
* default: false
* @param mixed $default
* value which is returned if optional=true and param is not set
*
* @return string
*/
protected function getBoolParam($param = null, $optional = false, $default = false)
{
$_default = '0';
if ($default) {
$_default = '1';
}
$param_value = $this->getParam($param, $optional, $_default);
if ($param_value && intval($param_value) != 0) {
return '1';
}
return '0';
}
/**
* get specific parameter which also has and unlimited-field
*