You are here

public function AdminSettingsForm::buildForm in CacheExclude 8

Same name and namespace in other branches
  1. 1.0.x src/Form/AdminSettingsForm.php \Drupal\cacheexclude\Form\AdminSettingsForm::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/AdminSettingsForm.php, line 32

Class

AdminSettingsForm
Contribute form.

Namespace

Drupal\cacheexclude\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('cacheexclude.settings');
  $form['cacheexclude_list'] = [
    '#type' => 'textarea',
    '#title' => t('Pages to exclude from caching'),
    '#default_value' => $config
      ->get('cacheexclude_list'),
    '#width' => 40,
    '#height' => 10,
    '#description' => $this
      ->t("Enter one page per line as Drupal paths. Begin link with leading slash. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", [
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    ]),
  ];
  $form['cacheexclude_node_types'] = [
    '#type' => 'checkboxes',
    '#title' => t('Content types to exclude from caching'),
    '#default_value' => $config
      ->get('cacheexclude_node_types') ? $config
      ->get('cacheexclude_node_types') : [],
    '#options' => node_type_get_names(),
    '#description' => $this
      ->t("Check all content types that you do not want to be cached."),
  ];
  return parent::buildForm($form, $form_state);
}