memcache-8.x-2.2/memcache_admin/src/Form/MemcacheAdminSettingsForm.php

memcache_admin/src/Form/MemcacheAdminSettingsForm.php
<?php

namespace Drupal\memcache_admin\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Memcache admin settings form.
 */
class MemcacheAdminSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'memcache_admin_admin_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['show_memcache_statistics'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Show memcache statistics at the bottom of each page'),
      '#default_value' => $this->config('memcache_admin.settings')->get('show_memcache_statistics'),
      '#description' => $this->t("These statistics will be visible to users with the 'access memcache statistics' permission."),
    ];

    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function getEditableConfigNames() {
    return ['memcache_admin.settings'];
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('memcache_admin.settings')
      ->set('show_memcache_statistics', (bool) $form_state->getValue('show_memcache_statistics'))
      ->save();

    parent::submitForm($form, $form_state);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc