refactoring

This commit is contained in:
Yuri Kuznetsov
2021-02-16 21:22:33 +02:00
parent 18537b9cdb
commit 2e7bc894f1
5 changed files with 265 additions and 123 deletions
+19 -1
View File
@@ -122,6 +122,10 @@ class Integration extends \Espo\Core\ORM\Entity
return parent::isAttributeChanged($name);
}
/**
* @deprecated
* @todo Make protected.
*/
public function populateFromArray(array $array, bool $onlyAccessible = true, bool $reset = false) : void
{
if ($reset) {
@@ -141,29 +145,43 @@ class Integration extends \Espo\Core\ORM\Entity
if (!is_null($value)) {
switch ($defs['type']) {
case self::VARCHAR:
break;
case self::BOOL:
$value = ($value === 'true' || $value === '1' || $value === true);
break;
case self::INT:
$value = intval($value);
break;
case self::FLOAT:
$value = floatval($value);
break;
case self::JSON_ARRAY:
$value = is_string($value) ? json_decode($value) : $value;
if (!is_array($value)) {
$value = null;
}
break;
case self::JSON_OBJECT:
$value = is_string($value) ? json_decode($value) : $value;
if (!($value instanceof \StdClass) && !is_array($value)) {
if (!($value instanceof StdClass) && !is_array($value)) {
$value = null;
}
break;
default:
break;
}
}