You are here

function blocktheme_save in Block Theme 8

Same name and namespace in other branches
  1. 5 blocktheme.module \blocktheme_save()
  2. 6 blocktheme.module \blocktheme_save()
  3. 7 blocktheme.module \blocktheme_save()

Save a new block a after the block form has been submitted.

1 string reference to 'blocktheme_save'
blocktheme_form_basic_block_content_form_alter in ./blocktheme.module
Form for adding a new block.

File

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

Code

function blocktheme_save($form, FormStateInterface &$form_state) {
  $var_name = $form_state
    ->getValue('info')[0]['value'];
  $blocktheme = blocktheme_get();
  $blocktheme_vars = blocktheme_get_vars();
  if ($form_state
    ->getValue('blocktheme')) {
    $blocktheme[$var_name] = $form_state
      ->getValue('blocktheme');
  }
  if ($form_state
    ->getValue('blocktheme_vars')) {
    $blocktheme_vars[$var_name] = blocktheme_format_vars($form_state
      ->getValue('blocktheme_vars'));
  }
  blocktheme_set($blocktheme, $blocktheme_vars);
  drupal_theme_rebuild();
}