You are here

private static function SmartDateTrait::arrayToRender in Smart Date 3.1.x

Same name and namespace in other branches
  1. 8.2 src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
  2. 3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
  3. 3.0.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
  4. 3.2.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
  5. 3.3.x src/SmartDateTrait.php \Drupal\smart_date\SmartDateTrait::arrayToRender()
  6. 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 493

Class

SmartDateTrait
Provides friendly methods for smart date range.

Namespace

Drupal\smart_date

Code

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;
}