You are here

function theme_ip_ban_country_table in IP Ban 8

Same name and namespace in other branches
  1. 7 ip_ban.admin.inc \theme_ip_ban_country_table()

Theme the IP Ban Country configuration table.

1 theme call to theme_ip_ban_country_table()
IpBanAdmin::buildForm in src/IpBanAdmin.php

File

./ip_ban.admin.inc, line 215
Administration functions for the IP Ban module.

Code

function theme_ip_ban_country_table($form) {
  $countries = Element::children($form['ip_ban_table']);
  $header = array(
    t('Country'),
    t('Policy'),
  );
  foreach ($countries as $country) {

    // Put the select element's title in its own cell.
    $country_name = $form['ip_ban_table'][$country]['#title'];
    unset($form['ip_ban_table'][$country]['#title']);
    $rows[] = array(
      $country_name,
      \Drupal::service("renderer")
        ->render($form['ip_ban_table'][$country]),
    );
  }

  // @see https://www.drupal.org/node/2195739
  $output = array(
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => array(
      'id' => 'ip-ban-country-listing-table',
      'style' => 'width: 50%',
    ),
  );
  return \Drupal::service('renderer')
    ->render($output);
}