mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-22 14:28:54 +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;
|
||||
} elseif ($column['type'] === 'Json') {
|
||||
$value = isset($value) ? json_encode($value) : '';
|
||||
} elseif($column['type'] === 'Serialize') {
|
||||
$value = $value->serialize();
|
||||
}
|
||||
|
||||
$query->insert($column['name'])
|
||||
|
|
@ -539,6 +541,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
|||
$reflectionProperty->setValue($obj, new \DateTime($value));
|
||||
} elseif (static::$columns[$column]['type'] === 'Json') {
|
||||
$reflectionProperty->setValue($obj, json_decode($value, true));
|
||||
} elseif (static::$columns[$column]['type'] === 'Serializable') {
|
||||
$member = $reflectionProperty->getValue($obj);
|
||||
$member->unserialize($value);
|
||||
} else {
|
||||
throw new \UnexpectedValueException('Value "' . static::$columns[$column]['type'] . '" is not supported.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user