You are here

public function AppAnalyticsSettingsForm::buildForm in Apigee Edge 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/AppAnalyticsSettingsForm.php, line 83

Class

AppAnalyticsSettingsForm
Provides a form for app analytics related configuration.

Namespace

Drupal\apigee_edge\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Portal environment is for internal use with integrated portals and
  // is not an actual environment for customers use.
  // To reduce confusion portal environment is hidden from configuration.
  $environments = $this->environmentController
    ->getEntityIds();
  $environments = array_combine($environments, $environments);
  unset($environments['portal']);
  $form['label'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Environment to query for analytics data'),
    '#collapsible' => FALSE,
  ];
  $form['label']['available_environments'] = [
    '#type' => 'checkboxes',
    '#required' => TRUE,
    '#title' => $this
      ->t('Which environments should be displayed on the form to query analytics data?'),
    '#default_value' => $this
      ->config('apigee_edge.common_app_settings')
      ->get('analytics_available_environments') ?: [],
    '#options' => $environments,
  ];
  $form['label']['environment'] = [
    '#type' => 'select',
    '#required' => TRUE,
    '#title' => $this
      ->t('Which environment should be selected by default?'),
    '#default_value' => $this
      ->config('apigee_edge.common_app_settings')
      ->get('analytics_environment'),
    '#options' => $environments,
  ];
  return parent::buildForm($form, $form_state);
}