- Fixed string's length based on annotation (if set)
This commit is contained in:
parent
2c7449b733
commit
1839726dc0
|
@ -159,6 +159,15 @@ trait EntityTrait {
|
||||||
$this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true);
|
$this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true);
|
||||||
}
|
}
|
||||||
elseif ( EntityField::isScalarType($field['type']) ) {
|
elseif ( EntityField::isScalarType($field['type']) ) {
|
||||||
|
|
||||||
|
if ( $field['type'] === 'string' ) {
|
||||||
|
$annotation = $entityResolver->searchFieldAnnotation($field['name'], new Field() );
|
||||||
|
|
||||||
|
if ( $annotation->length ?? null ) {
|
||||||
|
$value = substr($value, 0, $annotation->length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->{$field['name']} = $value;
|
$this->{$field['name']} = $value;
|
||||||
}
|
}
|
||||||
elseif ( ! $field['builtin'] ) {
|
elseif ( ! $field['builtin'] ) {
|
||||||
|
|
Loading…
Reference in New Issue