You are here

function blocktheme_update in Block Theme 8

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

Update an existing block after the block form has been submitted.

1 string reference to 'blocktheme_update'
blocktheme_form_block_form_alter in ./blocktheme.module
Form for updating a block.

File

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

Code

function blocktheme_update($form, FormStateInterface &$form_state) {
  $var_name = $form_state
    ->getValue('id');
  $blocktheme = blocktheme_get();
  $blocktheme_vars = blocktheme_get_vars();
  if (!$form_state
    ->getValue('custom_block_theme')['blocktheme']) {
    unset($blocktheme[$var_name]);
  }
  else {
    $blocktheme[$var_name] = $form_state
      ->getValue('custom_block_theme')['blocktheme'];
  }
  if (!$form_state
    ->getValue('custom_block_theme')['blocktheme_vars']) {
    unset($blocktheme_vars[$var_name]);
  }
  else {
    $blocktheme_vars[$var_name] = blocktheme_format_vars($form_state
      ->getValue('custom_block_theme')['blocktheme_vars']);
  }
  blocktheme_set($blocktheme, $blocktheme_vars);
  drupal_theme_rebuild();
}