You are here

public function GatsbyFastbuildsAdminForm::buildForm in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x modules/gatsby_fastbuilds/src/Form/GatsbyFastbuildsAdminForm.php \Drupal\gatsby_fastbuilds\Form\GatsbyFastbuildsAdminForm::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

modules/gatsby_fastbuilds/src/Form/GatsbyFastbuildsAdminForm.php, line 32

Class

GatsbyFastbuildsAdminForm
Defines an admin for for Gatsby fastbuilds.

Namespace

Drupal\gatsby_fastbuilds\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('gatsby_fastbuilds.settings');
  $form['log_published'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Only log entities for published content'),
    '#description' => $this
      ->t('Depending on your content workflow, you may only
        want fastbuilds to work for published content. By checking this box
        only published content entities will be logged and available for
        Fastbuilds.'),
    '#default_value' => $config
      ->get('log_published') !== NULL ? $config
      ->get('log_published') : FALSE,
    '#weight' => 0,
  ];
  $form['delete_log_entities'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Delete Old Gatsby Fastbuilds Log Entities'),
    '#description' => $this
      ->t('Enable this to automatically clean up old
        Fastbuilds log entities on cron runs.'),
    '#default_value' => $config
      ->get('delete_log_entities'),
    '#weight' => 1,
  ];
  $form['log_expiration'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Fastbuilds Log Expiration'),
    '#description' => $this
      ->t('How long do you want to store the Fastbuild
        log entities (after this time they will be automatically deleted and a
        full Gatsby rebuild will be required)?'),
    // Expiration values are stored in seconds.
    '#options' => [
      '604800' => $this
        ->t('7 days'),
      '1209600' => $this
        ->t('14 days'),
      '2592000' => $this
        ->t('30 days'),
      '5184000' => $this
        ->t('60 days'),
      '7776000' => $this
        ->t('90 days'),
    ],
    '#default_value' => $config
      ->get('log_expiration'),
    '#weight' => 2,
    '#states' => [
      'visible' => [
        ':input[name="delete_log_entities"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}