You are here

function theme_emaillog_admin_settings in Logging and alerts 8

Same name and namespace in other branches
  1. 6.2 emaillog/emaillog.admin.inc \theme_emaillog_admin_settings()
  2. 7.2 emaillog/emaillog.admin.inc \theme_emaillog_admin_settings()
  3. 2.0.x emaillog/emaillog.module \theme_emaillog_admin_settings()

Themes admin settings form.

1 string reference to 'theme_emaillog_admin_settings'
emaillog_theme in emaillog/emaillog.module
Implements hook_theme().

File

emaillog/emaillog.module, line 47
Drupal Module: Email Logging and Alerts.

Code

function theme_emaillog_admin_settings($variables) {
  $form = $variables['form'];
  $severity_levels = RfcLogLevel::getLevels();
  foreach (Element::children($form['debug_info']['variable']) as $key) {
    $row = [];

    // Permission row.
    $row[] = [
      'data' => render($form['debug_info']['variable'][$key]),
      'class' => [
        'variable',
      ],
    ];
    foreach (array_keys($severity_levels) as $level_id) {
      $element = $form['debug_info'][$level_id];
      $form['debug_info'][$level_id][$key]['#title'] = $element['#title'] . ' : ' . $form['debug_info']['variable'][$key]['#markup'];
      $form['debug_info'][$level_id][$key]['#title_display'] = 'invisible';
      $row[] = [
        'data' => render($form['debug_info'][$level_id][$key]),
        'class' => [
          'checkbox',
        ],
        'title' => $element['#title'] . ' : ' . $form['debug_info']['variable'][$key]['#markup'],
      ];
    }
    $rows[] = $row;
  }
  $header = [
    '',
  ];
  foreach (array_keys($severity_levels) as $level_id) {
    $element = $form['debug_info'][$level_id];
    $header[] = [
      'data' => $element['#title'],
      'class' => [
        'checkbox',
      ],
    ];

    // Mark the checkboxes parent as rendered.
    $form['debug_info'][$level_id]['#printed'] = TRUE;
  }
  $table = [
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => [
      'id' => 'permissions',
    ],
  ];

  // Put the table with all checkboxes inside a fieldset.
  $form['debug_info']['variables'] = [
    '#type' => 'markup',
    '#markup' => render($table),
  ];

  // Render and return all remaining elements.
  return \Drupal::service('renderer')
    ->render($form);
}