template_preprocess_maintenance_task_list

template_preprocess_maintenance_task_list(&$variables)

Prepares variables for maintenance task list templates.

Default template: maintenance-task-list.html.twig.

Parameters

array $variables: An associative array containing:

  • items: An associative array of maintenance tasks. It's the caller's responsibility to ensure this array's items contain no dangerous HTML such as <script> tags.
  • active: The key for the currently active maintenance task.

File

core/includes/theme.inc, line 1163
The theme system, which controls the output of Drupal.

Code

function template_preprocess_maintenance_task_list(&$variables) {
  $items = $variables['items'];
  $active = $variables['active'];

  $done = isset($items[$active]) || $active == NULL;
  foreach ($items as $k => $item) {
    $variables['tasks'][$k]['item'] = $item;
    $variables['tasks'][$k]['attributes'] = new Attribute();
    if ($active == $k) {
      $variables['tasks'][$k]['attributes']->addClass('is-active');
      $variables['tasks'][$k]['status'] = t('active');
      $done = FALSE;
    }
    else {
      if ($done) {
        $variables['tasks'][$k]['attributes']->addClass('done');
        $variables['tasks'][$k]['status'] = t('done');
      }
    }
  }
}
doc_Drupal
2016-10-29 09:46:45
Comments
Leave a Comment

Please login to continue.