You are here

function template_preprocess_fullcalendar_legend in FullCalendar 8

Same name and namespace in other branches
  1. 8.5 modules/fullcalendar_legend/fullcalendar_legend.theme.inc \template_preprocess_fullcalendar_legend()
  2. 8.2 modules/fullcalendar_legend/fullcalendar_legend.theme.inc \template_preprocess_fullcalendar_legend()
  3. 8.3 fullcalendar_legend/fullcalendar_legend.theme.inc \template_preprocess_fullcalendar_legend()
  4. 8.4 modules/fullcalendar_legend/fullcalendar_legend.theme.inc \template_preprocess_fullcalendar_legend()
  5. 7.2 fullcalendar_legend/theme/theme.inc \template_preprocess_fullcalendar_legend()

Build the legend as a render array.

File

fullcalendar_legend/fullcalendar_legend.theme.inc, line 13
Theme functions for FullCalendar Legend.

Code

function template_preprocess_fullcalendar_legend(&$variables) {
  foreach ($variables['types'] as $type_name => $type) {
    $element[$type_name] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => _fullcalendar_legend_get_classes($type),
        'entity_type' => $type['entity_type'],
        'bundle' => $type['bundle'],
        'field' => $type['field_name'],
      ],
    ];

    // Sanitize the label.
    $type['label'] = Html::escape($type['label']);
    if (isset($type['uri'])) {
      $element[$type_name]['type'] = [
        '#type' => 'link',
        '#href' => $type['uri']['path'],
        '#options' => isset($type['uri']['options']) ? $type['uri']['options'] : [],
        '#title' => $type['label'],
      ];
    }
    else {
      $element[$type_name]['type'] = [
        '#markup' => $type['label'],
      ];
    }
  }
  $element['#attached']['library'][] = 'fullcalendar_legend/fullcalendar_legend';
  $variables['element'] = $element;
}