mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
add date time immutable
This commit is contained in:
parent
ace6e49380
commit
6035870c1f
|
|
@ -1063,7 +1063,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
return (float) $value;
|
||||
} elseif ($type === 'bool') {
|
||||
return (bool) $value;
|
||||
} elseif ($type === 'DateTime') {
|
||||
} elseif ($type === 'DateTime' || $type === 'DateTimeImmutable') {
|
||||
return $value === null ? null : $value->format('Y-m-d H:i:s');
|
||||
} elseif ($type === 'Json' || $type === 'jsonSerializable') {
|
||||
return (string) \json_encode($value);
|
||||
|
|
@ -2250,6 +2250,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$value = ArrayUtils::setArray($arrayPath, $aValue, $value, '/', true);
|
||||
}
|
||||
|
||||
$refProp->setValue($obj, $value);
|
||||
} elseif ($def['type'] === 'DateTimeImmutable') {
|
||||
$value = $value === null ? null : new \DateTimeImmutable($value);
|
||||
if ($hasPath) {
|
||||
$value = ArrayUtils::setArray($arrayPath, $aValue, $value, '/', true);
|
||||
}
|
||||
|
||||
$refProp->setValue($obj, $value);
|
||||
} elseif ($def['type'] === 'Json') {
|
||||
if ($hasPath) {
|
||||
|
|
@ -2313,6 +2320,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$value = ArrayUtils::setArray($arrayPath, $aValue, $value, '/', true);
|
||||
}
|
||||
|
||||
$refProp->setValue($obj, $value);
|
||||
} elseif ($def['mapper']::$columns[$column]['type'] === 'DateTimeImmutable') {
|
||||
$value = $value === null ? null : new \DateTimeImmutable($value);
|
||||
if ($hasPath) {
|
||||
$value = ArrayUtils::setArray($arrayPath, $aValue, $value, '/', true);
|
||||
}
|
||||
|
||||
$refProp->setValue($obj, $value);
|
||||
} elseif ($def['mapper']::$columns[$column]['type'] === 'Json') {
|
||||
if ($hasPath) {
|
||||
|
|
@ -2375,6 +2389,8 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
\settype($value, static::$columns[$column]['type']);
|
||||
} elseif (static::$columns[$column]['type'] === 'DateTime') {
|
||||
$value = $value === null ? null : new \DateTime($value);
|
||||
} elseif (static::$columns[$column]['type'] === 'DateTimeImmutable') {
|
||||
$value = $value === null ? null : new \DateTimeImmutable($value);
|
||||
} elseif (static::$columns[$column]['type'] === 'Json') {
|
||||
$value = \json_decode($value, true);
|
||||
}
|
||||
|
|
@ -2397,6 +2413,8 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
\settype($value, $def['mapper']::$columns[$column]['type']);
|
||||
} elseif ($def['mapper']::$columns[$column]['type'] === 'DateTime') {
|
||||
$value = $value === null ? null : new \DateTime($value);
|
||||
} elseif ($def['mapper']::$columns[$column]['type'] === 'DateTimeImmutable') {
|
||||
$value = $value === null ? null : new \DateTimeImmutable($value);
|
||||
} elseif ($def['mapper']::$columns[$column]['type'] === 'Json') {
|
||||
$value = \json_decode($value, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ final class StringUtils
|
|||
return $element ? '1' : '0';
|
||||
} elseif ($element === null) {
|
||||
return null;
|
||||
} elseif ($element instanceof \DateTime) {
|
||||
} elseif ($element instanceof \DateTimeInterface) {
|
||||
return $element->format('Y-m-d H:i:s');
|
||||
} elseif ($element instanceof RenderableInterface) {
|
||||
return $element->render();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user