You are here

public function HealthCheckSettingsForm::buildForm in Health Check Url 8

Same name and namespace in other branches
  1. 8.3 src/Form/HealthCheckSettingsForm.php \Drupal\health_check_url\Form\HealthCheckSettingsForm::buildForm()
  2. 8.2 src/Form/HealthCheckSettingsForm.php \Drupal\health_check_url\Form\HealthCheckSettingsForm::buildForm()

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/HealthCheckSettingsForm.php, line 32

Class

HealthCheckSettingsForm
Configure health settings for this site.

Namespace

Drupal\health_check_url\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('health_check_url.settings');
  $options = [
    "timestamp" => time(),
    "string" => $config
      ->get('string'),
    "stringWithTimestamp" => $config
      ->get('string') . ' - ' . time(),
    "stringWithDateTime" => $config
      ->get('string') . ' ' . strftime("at %T on %D"),
    "stringWithDateTimestamp" => $config
      ->get('string') . ' ' . strftime("at %T on %D") . ' (' . time() . ')',
  ];
  $form['type'] = [
    '#title' => $this
      ->t('Response Type'),
    '#type' => 'radios',
    '#options' => $options,
    '#default_value' => $config
      ->get('type'),
  ];
  $form['string'] = [
    '#title' => $this
      ->t('Text'),
    '#type' => 'textfield',
    '#description' => $this
      ->t("Enter the text to display in output. works only if the above selected Response type is contains text"),
    '#default_value' => $config
      ->get('string'),
  ];
  $form['endpoint'] = [
    '#title' => $this
      ->t('Endpoint'),
    '#type' => 'textfield',
    '#description' => $this
      ->t("Enter the path for health check up"),
    '#default_value' => $config
      ->get('endpoint'),
  ];
  $form['maintainence_access'] = [
    '#title' => $this
      ->t('Accessible on maintainence mode'),
    '#type' => 'checkbox',
    '#description' => $this
      ->t("Defines whether the endpoint is accessible when site is on maintainence mode "),
    '#default_value' => $config
      ->get('maintainence_access'),
  ];
  return parent::buildForm($form, $form_state);
}