You are here

function template_preprocess_language_content_settings_table in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/language.admin.inc \template_preprocess_language_content_settings_table()
  2. 9 core/modules/language/language.admin.inc \template_preprocess_language_content_settings_table()

Prepares variables for language content settings table templates.

Default template: language-content-settings-table.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #bundle_label, #title.

File

core/modules/language/language.admin.inc, line 106
Administration functions for language.module.

Code

function template_preprocess_language_content_settings_table(&$variables) {

  // Add a render element representing the bundle language settings table.
  $element = $variables['element'];
  $header = [
    [
      'data' => $element['#bundle_label'],
      'class' => [
        'bundle',
      ],
    ],
    [
      'data' => t('Configuration'),
      'class' => [
        'operations',
      ],
    ],
  ];
  $rows = [];
  foreach (Element::children($element) as $bundle) {
    $rows[$bundle] = [
      'data' => [
        [
          'data' => [
            '#prefix' => '<label>',
            '#suffix' => '</label>',
            '#plain_text' => $element[$bundle]['settings']['#label'],
          ],
          'class' => [
            'bundle',
          ],
        ],
        [
          'data' => $element[$bundle]['settings'],
          'class' => [
            'operations',
          ],
        ],
      ],
      'class' => [
        'bundle-settings',
      ],
    ];
  }
  $variables['title'] = $element['#title'];
  $variables['build'] = [
    '#header' => $header,
    '#rows' => $rows,
    '#type' => 'table',
  ];
}