You are here

ConfigFormBase.php in Zoom API 8

Same filename and directory in other branches
  1. 2.0.x src/Form/ConfigFormBase.php

File

src/Form/ConfigFormBase.php
View source
<?php

namespace Drupal\zoomapi\Form;

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

/**
 * Config form base for our config form.
 */
abstract class ConfigFormBase extends DrupalConfigFormBase {
  const CONFIG_NAME = 'zoomapi.settings';

  /**
   * {@inheritdoc}
   */
  public function getEditableConfigNames() {
    return [
      self::CONFIG_NAME,
    ];
  }

  /**
   * Returns this modules configuration object.
   */
  protected function getConfig() {
    return $this
      ->config(self::CONFIG_NAME);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this
      ->getConfig();
    $values = $form_state
      ->getValues();
    foreach ($values as $key => $value) {
      $config
        ->set($key, $value);
    }
    $config
      ->save();
  }

}

Classes

Namesort descending Description
ConfigFormBase Config form base for our config form.