private static function SmartDateTrait::array_to_render in Smart Date 8
Helper function to turn a simple, nested array into a render array.
Parameters
array $array: An array, potentially nested, to be converted.
Return value
array The nested render array.
1 call to SmartDateTrait::array_to_render()
- SmartDateTrait::rangeFormat in src/
SmartDateTrait.php - Format a provided range, using provided settings.
File
- src/
SmartDateTrait.php, line 299
Class
- SmartDateTrait
- Provides friendly methods for smart date range.
Namespace
Drupal\smart_dateCode
private static function array_to_render($array) {
if (!is_array($array)) {
return false;
}
$output = [];
// Iterate though the array
foreach ($array as $key => $child) {
$child == array_pop($array);
if (is_array($child)) {
$output[$key] = static::array_to_render($child);
}
else {
$output[$key] = [
'#markup' => $child,
];
}
}
return $output;
}