public function IgnoredModulesForm::buildForm in Nagios Monitoring 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ IgnoredModulesForm.php, line 65
Class
Namespace
Drupal\nagios\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('nagios.settings');
$enabled = TRUE;
$settings_url = Url::fromRoute('nagios.settings')
->toString();
// Is the nagios module itself disabled?
$nagios_hooks_enabled = $config
->get('nagios.enable.nagios') ?? TRUE;
if (!$nagios_hooks_enabled) {
\Drupal::messenger()
->addMessage($this
->t('These settings are not available, because the nagios module is not enabled within the <a href="@nagios-settings">nagios settings</a>.', [
'@nagios-settings' => $settings_url,
]), 'warning');
$enabled = FALSE;
}
// Is "Checking of hook_requirements." disabled?
if (!$config
->get('nagios.function.requirements')) {
\Drupal::messenger()
->addMessage($this
->t('These settings are not available, because the requirements check is not enabled within the <a href="@nagios-settings">nagios settings</a>.', [
'@nagios-settings' => $settings_url,
]), 'warning');
$enabled = FALSE;
}
$this
->addDescription($form);
$this
->buildTable($form, $enabled);
$form = parent::buildForm($form, $form_state);
if (!$enabled) {
$form['actions']['submit']['#disabled'] = TRUE;
}
return $form;
}