HOR-1076: Create Process Variable End point esconde las propiedades de la variable
validacion de tipo
This commit is contained in:
@@ -5,6 +5,8 @@ use \G;
|
||||
|
||||
class Variable
|
||||
{
|
||||
public $variableTypes = array('string', 'integer', 'float', 'boolean', 'datetime', 'grid', 'array', 'file');
|
||||
|
||||
/**
|
||||
* Create Variable for a Process
|
||||
*
|
||||
@@ -44,6 +46,7 @@ class Variable
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
|
||||
}
|
||||
if (isset($arrayData["VAR_FIELD_TYPE"])) {
|
||||
$arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
$variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
|
||||
@@ -151,6 +154,7 @@ class Variable
|
||||
$variable->setVarName($arrayData["VAR_NAME"]);
|
||||
}
|
||||
if (isset($arrayData["VAR_FIELD_TYPE"])) {
|
||||
$arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
$variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]);
|
||||
}
|
||||
if (isset($arrayData["VAR_FIELD_SIZE"])) {
|
||||
@@ -1076,4 +1080,13 @@ class Variable
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function validateVarFieldType($type)
|
||||
{
|
||||
$vType = strtolower($type);
|
||||
if(!in_array($vType, $this->variableTypes)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
|
||||
}
|
||||
return $vType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user