fixed meta param for email template
This commit is contained in:
@@ -35,7 +35,15 @@ public function render(array $template, array $ctx): array
|
|||||||
return $m[0];
|
return $m[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) data_get($map, $key, '');
|
$value = data_get($map, $key, '');
|
||||||
|
|
||||||
|
// If the resolved value is an array (e.g. {{ contract.meta }} used directly),
|
||||||
|
// return empty string instead of triggering "Array to string conversion".
|
||||||
|
if (is_array($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $value;
|
||||||
}, $input);
|
}, $input);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -176,8 +184,17 @@ protected function buildMap(array $ctx): array
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$meta = data_get($co, 'meta');
|
$meta = data_get($co, 'meta');
|
||||||
|
if (is_string($meta)) {
|
||||||
|
$meta = json_decode($meta, true) ?? [];
|
||||||
|
}
|
||||||
if (is_array($meta)) {
|
if (is_array($meta)) {
|
||||||
$out['contract']['meta'] = $meta;
|
// Flatten meta entries. Supports two formats:
|
||||||
|
// - Structured: { "sklic": { "value": "...", "type": "string", ... } } → extract 'value'
|
||||||
|
// - Plain: { "sklic": "..." } → use as-is
|
||||||
|
$out['contract']['meta'] = array_map(
|
||||||
|
fn ($item) => (is_array($item) && array_key_exists('value', $item)) ? $item['value'] : $item,
|
||||||
|
$meta
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($ctx['activity'])) {
|
if (isset($ctx['activity'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user