function nagios_form_system_theme_settings_alter in Nagios Monitoring 8
Same name and namespace in other branches
- 7 nagios.module \nagios_form_system_theme_settings_alter()
Implements hook_form_FORM_ID_alter().
Modify the module display view by adding a nagios ignore link to every module description.
Parameters
array $form:
FormStateInterface $form_state:
File
- ./
nagios.module, line 200 - Main file for Nagios service monitoring.
Code
function nagios_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
if (isset($form['confirm']) || !Drupal::currentUser()
->hasPermission('administer nagios ignore')) {
return;
}
// Grab the name of the theme.
$buildinfo = $form_state
->getBuildInfo();
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') ?: [];
// Check to see if the theme is provided by core, or if it's contrib/custom.
$projects_data = Drupal::service('update.manager')
->getProjects();
if (array_key_exists($theme_name, $projects_data)) {
// This is a settings page for a non-core theme, so add the checkbox.
$form['nagios'] = [
'#type' => 'fieldset',
'#title' => t('Nagios Monitoring'),
'nagios_ignore' => [
'#type' => 'checkbox',
'#title' => t('Ignore from Nagios'),
'#weight' => 200,
'#default_value' => !empty($nagios_ignored_themes[$theme_name]),
],
];
$form['#submit'][] = 'nagios_system_theme_settings_form_submit';
}
}
}