mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
backup framework, add some plumbing to ease model usage.
This commit is contained in:
parent
d803e53f5f
commit
d465ef2045
@ -94,4 +94,36 @@ abstract class Base
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set model properties
|
||||
* @param OPNsense\Base\BaseModel $mdl model to set properties to
|
||||
* @param array $properties named
|
||||
*/
|
||||
protected function setModelProperties($mdl, $properties)
|
||||
{
|
||||
foreach ($properties as $key => $value) {
|
||||
$node = $mdl->getNodeByReference($key);
|
||||
$node_class = get_class($node);
|
||||
if ( $node_class == "OPNsense\Base\FieldTypes\BooleanField") {
|
||||
$node->setValue(empty($value) ? "0" : "1");
|
||||
} else {
|
||||
$node->setValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate model and return simple array with validation messages
|
||||
* @param OPNsense\Base\BaseModel $mdl model to set properties to
|
||||
* @return array
|
||||
*/
|
||||
protected function validateModel($mdl)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($mdl->performValidation() as $validation_message) {
|
||||
$result[] = (string)$validation_message;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user