mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +00:00
Support serializable member variables
This commit is contained in:
parent
a8e9c7afab
commit
23e6f36e1a
|
|
@ -260,6 +260,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$value = isset($value) ? $value->format('Y-m-d H:i:s') : null;
|
$value = isset($value) ? $value->format('Y-m-d H:i:s') : null;
|
||||||
} elseif ($column['type'] === 'Json') {
|
} elseif ($column['type'] === 'Json') {
|
||||||
$value = isset($value) ? json_encode($value) : '';
|
$value = isset($value) ? json_encode($value) : '';
|
||||||
|
} elseif($column['type'] === 'Serialize') {
|
||||||
|
$value = $value->serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->insert($column['name'])
|
$query->insert($column['name'])
|
||||||
|
|
@ -539,6 +541,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$reflectionProperty->setValue($obj, new \DateTime($value));
|
$reflectionProperty->setValue($obj, new \DateTime($value));
|
||||||
} elseif (static::$columns[$column]['type'] === 'Json') {
|
} elseif (static::$columns[$column]['type'] === 'Json') {
|
||||||
$reflectionProperty->setValue($obj, json_decode($value, true));
|
$reflectionProperty->setValue($obj, json_decode($value, true));
|
||||||
|
} elseif (static::$columns[$column]['type'] === 'Serializable') {
|
||||||
|
$member = $reflectionProperty->getValue($obj);
|
||||||
|
$member->unserialize($value);
|
||||||
} else {
|
} else {
|
||||||
throw new \UnexpectedValueException('Value "' . static::$columns[$column]['type'] . '" is not supported.');
|
throw new \UnexpectedValueException('Value "' . static::$columns[$column]['type'] . '" is not supported.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user