private static function SmartDateTrait::arrayToRender in Smart Date 3.2.x
Same name and namespace in other branches
- 8.2 src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
- 3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
- 3.0.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
- 3.1.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
- 3.3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
- 3.4.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
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::arrayToRender()
- SmartDateTrait::rangeFormat in src/
SmartDateTrait.php - Format a provided range, using provided settings.
File
- src/
SmartDateTrait.php, line 535
Class
- SmartDateTrait
- Provides friendly methods for smart date range.
Namespace
Drupal\smart_dateCode
private static function arrayToRender(array $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::arrayToRender($child);
}
else {
$output[$key] = [
'#markup' => $child,
];
}
}
return $output;
}