You are here

public function EdgeEntityCacheConfigFormBase::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/EdgeEntityCacheConfigFormBase.php, line 35

Class

EdgeEntityCacheConfigFormBase
Base cache expiration config form for Apigee Edge entities.

Namespace

Drupal\apigee_edge\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config($this
    ->getConfigNameWithCacheSettings());
  $form['cache'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Caching'),
    '#collapsible' => FALSE,
  ];
  $form['cache']['cache_expiration'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Expires'),
    '#description' => $this
      ->t('Number of <strong>seconds</strong> until a cached item expires. Use <em>-1</em> to cache items until they have been updated on the Developer Portal (ignore changes made on the Apigee Edge Management UI or in an external application). Use <em>0</em> to completely disable caching.'),
    '#default_value' => $config
      ->get('cache_expiration'),
    '#min' => -1,
    '#required' => TRUE,
  ];
  $form['cache']['actions'] = [
    '#type' => 'actions',
  ];
  $form['cache']['actions']['invalidate_cache'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Invalidate cache'),
    '#limit_validation_errors' => [],
    '#submit' => [
      '::invalidateCache',
    ],
  ];
  return parent::buildForm($form, $form_state);
}