Skip to content

Commit

Permalink
fix(EntityGenerator): Nullable $field->getDefaultValues()
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Mar 23, 2023
1 parent c5c9e6f commit 297f099
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 0 additions & 12 deletions lib/EntityGenerator/src/Field/NonVirtualFieldGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ protected function getFieldLength(): ?int
};
}

protected function getMaxDefaultValuesLength(): int
{
// get max length of exploded default values
$max = 0;
foreach (explode(',', $this->field->getDefaultValues()) as $value) {
$value = trim($value);
$max = max($max, strlen($value));
}

return $max > 0 ? $max : 250;
}

protected function isExcludingFieldFromJmsSerialization(): bool
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/RoadizCoreBundle/src/NodeType/DefaultValuesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getDefaultValuesAmongAllFields(NodeTypeFieldInterface $field): a
* SQL field won't be shared between all node types.
*/
if ($this->inheritanceType === Configuration::INHERITANCE_TYPE_JOINED) {
return array_map('trim', explode(',', $field->getDefaultValues()));
return array_map('trim', explode(',', $field->getDefaultValues() ?? ''));
} else {
/*
* With single table inheritance, we need to get all default values
Expand All @@ -43,7 +43,7 @@ public function getDefaultValuesAmongAllFields(NodeTypeFieldInterface $field): a
'type' => $field->getType(),
]);
foreach ($nodeTypeFields as $nodeTypeField) {
$defaultValues = array_merge($defaultValues, array_map('trim', explode(',', $nodeTypeField->getDefaultValues())));
$defaultValues = array_merge($defaultValues, array_map('trim', explode(',', $nodeTypeField->getDefaultValues() ?? '')));
}
return $defaultValues;
}
Expand Down

0 comments on commit 297f099

Please sign in to comment.