You are here

function nagios_system_theme_settings_form_submit in Nagios Monitoring 8

Same name and namespace in other branches
  1. 7 nagios.module \nagios_system_theme_settings_form_submit()

Additional system theme settings form submit handler.

Saves the Nagios theme ignore status to the 'nagios_ignored_themes' variable. Variable contains an array of theme names to be ignored in the form 'theme_machine_name' => TRUE.

Parameters

array $form:

FormStateInterface $form_state:

1 string reference to 'nagios_system_theme_settings_form_submit'
nagios_form_system_theme_settings_alter in ./nagios.module
Implements hook_form_FORM_ID_alter().

File

./nagios.module, line 244
Main file for Nagios service monitoring.

Code

function nagios_system_theme_settings_form_submit(&$form, FormStateInterface $form_state) {
  $buildinfo = $form_state
    ->getBuildInfo();

  // Grab the name of the theme.
  if (!empty($buildinfo['args'][0])) {
    $theme_name = Html::escape($buildinfo['args'][0]);
    $config = Drupal::config('nagios.settings');
    $nagios_ignored_themes = $config
      ->get('nagios.ignored_themes') ?: [];
    if ($form_state
      ->getValue('nagios_ignore')) {
      $nagios_ignored_themes[$theme_name] = TRUE;
    }
    else {
      unset($nagios_ignored_themes[$theme_name]);
    }
    Drupal::configFactory()
      ->getEditable('nagios.settings')
      ->set('nagios.ignored_themes', $nagios_ignored_themes)
      ->save();
  }
}