You are here

function blocktheme_form_block_admin_display_form_alter in Block Theme 8

Add new column with name of template to the blocks list page.

File

./blocktheme.module, line 141
Provides a configuration option to select custom themes for blocks

Code

function blocktheme_form_block_admin_display_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
  $config = \Drupal::config('blocktheme.settings')
    ->get('blocktheme_show_custom_block_theme');
  if (!empty($config)) {
    $form['blocks']['#header'][] = t('Custom theme');
    foreach ($form['blocks'] as $block => $parametrs) {
      if (isset($parametrs['message'])) {
        $form['blocks'][$block]['message']['#wrapper_attributes']['colspan']++;
      }
      if (isset($parametrs['title'])) {
        $form['blocks'][$block]['title']['#wrapper_attributes']['colspan']++;
      }
      if (isset($parametrs['weight'])) {
        $template = blocktheme_get_theme_name($block);
        $form['blocks'][$block][] = array(
          '#markup' => !empty($template) ? $template : '',
        );
      }
    }
  }
}