- Fixed string's length based on annotation (if set)

This commit is contained in:
Dave Mc Nicoll 2020-04-14 11:36:55 -04:00
parent 2c7449b733
commit 1839726dc0
1 changed files with 9 additions and 0 deletions

View File

@ -159,6 +159,15 @@ trait EntityTrait {
$this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true);
}
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;
}
elseif ( ! $field['builtin'] ) {