Upgrade to 3.9.3
This commit is contained in:
@@ -202,6 +202,18 @@ class BlocksField extends FieldClass
|
||||
return $this->valueToJson($blocks, $this->pretty());
|
||||
}
|
||||
|
||||
protected function setDefault($default = null)
|
||||
{
|
||||
// set id for blocks if not exists
|
||||
if (is_array($default) === true) {
|
||||
array_walk($default, function (&$block) {
|
||||
$block['id'] ??= Str::uuid();
|
||||
});
|
||||
}
|
||||
|
||||
parent::setDefault($default);
|
||||
}
|
||||
|
||||
protected function setFieldsets($fieldsets, $model)
|
||||
{
|
||||
if (is_string($fieldsets) === true) {
|
||||
|
||||
@@ -115,6 +115,32 @@ class LayoutField extends BlocksField
|
||||
return $routes;
|
||||
}
|
||||
|
||||
protected function setDefault($default = null)
|
||||
{
|
||||
// set id for layouts, columns and blocks within layout if not exists
|
||||
if (is_array($default) === true) {
|
||||
array_walk($default, function (&$layout) {
|
||||
$layout['id'] ??= Str::uuid();
|
||||
|
||||
// set columns id within layout
|
||||
if (isset($layout['columns']) === true) {
|
||||
array_walk($layout['columns'], function (&$column) {
|
||||
$column['id'] ??= Str::uuid();
|
||||
|
||||
// set blocks id within column
|
||||
if (isset($column['blocks']) === true) {
|
||||
array_walk($column['blocks'], function (&$block) {
|
||||
$block['id'] ??= Str::uuid();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
parent::setDefault($default);
|
||||
}
|
||||
|
||||
protected function setLayouts(array $layouts = [])
|
||||
{
|
||||
$this->layouts = array_map(
|
||||
|
||||
@@ -838,11 +838,13 @@ abstract class FieldClass
|
||||
*/
|
||||
protected function valueToJson(array $value = null, bool $pretty = false): string
|
||||
{
|
||||
$constants = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||
|
||||
if ($pretty === true) {
|
||||
return json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$constants |= JSON_PRETTY_PRINT;
|
||||
}
|
||||
|
||||
return json_encode($value);
|
||||
return json_encode($value, $constants);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user