You are here

class SettingsForm in Akamai 8.2

Same name and namespace in other branches
  1. 8 lib/Drupal/akamai/Form/SettingsForm.php \Drupal\akamai\Form\SettingsForm

Defines a form that configures Akamai settings.

Hierarchy

Expanded class hierarchy of SettingsForm

1 string reference to 'SettingsForm'
akamai.routing.yml in ./akamai.routing.yml
akamai.routing.yml

File

src/Form/SettingsForm.php, line 16
Contains \Drupal\akamai\Form\SettingsForm.

Namespace

Drupal\akamai\Form
View source
class SettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'akamai_admin_settings_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state) {
    $akamai_config = $this
      ->config('akamai.settings');
    $form['akamai_restapi'] = array(
      '#type' => 'textfield',
      '#title' => t('REST API URL'),
      '#default_value' => $akamai_config
        ->get('restapi'),
      '#description' => t('The URL of the Akamai REST API call e.g. "https://api.ccu.akamai.com/ccu/v2/queues/default"'),
    );
    $form['akamai_basepath'] = array(
      '#type' => 'textfield',
      '#title' => t('Base Path'),
      '#default_value' => $akamai_config
        ->get('basepath'),
      '#description' => t('The URL of the base path (fully qualified domain name) of the site.  This will be used as a prefix for all cache clears (Akamai indexs on the full URI). e.g. "http://www.example.com"'),
    );
    $form['akamai_username'] = array(
      '#type' => 'textfield',
      '#title' => t('Cache clearing user'),
      '#default_value' => $akamai_config
        ->get('username'),
      '#description' => t('The user name of the account being used for cache clearing (most likely an email)'),
    );
    $form['akamai_password'] = array(
      '#type' => 'textfield',
      '#title' => t('Cache clearing password'),
      '#default_value' => $akamai_config
        ->get('password'),
      '#description' => t('The password of the cache clearing user'),
    );
    $form['akamai_domain'] = array(
      '#type' => 'select',
      '#title' => t('Domain'),
      '#default_value' => $akamai_config
        ->get('domain'),
      '#options' => array(
        'staging' => t('Staging'),
        'production' => t('Production'),
      ),
      '#description' => t('The Akamai domain to use for cache clearing'),
    );
    $form['akamai_action'] = array(
      '#type' => 'select',
      '#title' => t('Clearing Action Type Default'),
      '#default_value' => $akamai_config
        ->get('action'),
      '#options' => array(
        'remove' => t('Remove'),
        'invalidate' => t('Invalidate'),
      ),
      '#description' => t('The default clearing action.  The options are <em>remove</em> (which removes the item from the Akamai cache) and <em>invalidate</em> (which leaves the item in the cache, but invalidates it so that the origin will be hit on the next request)'),
    );
    $form['akamai_email'] = array(
      '#type' => 'textfield',
      '#title' => t('Email Notification Override'),
      '#default_value' => $akamai_config
        ->get('email'),
      '#description' => t('If this email address is specified all cache clearing requests will send notifications to this address.  If this address is not specified, the email address of the user executing the request will be used.'),
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, array &$form_state) {
    parent::validateForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this
      ->config('akamai.settings')
      ->set('wsdl', $form_state['values']['akamai_wsdl'])
      ->set('restapi', $form_state['values']['akamai_restapi'])
      ->set('restapi_default', $form_state['values']['akamai_restapi_default'])
      ->set('basepath', $form_state['values']['akamai_basepath'])
      ->set('username', $form_state['values']['akamai_username'])
      ->set('password', $form_state['values']['akamai_password'])
      ->set('domain', $form_state['values']['akamai_domain'])
      ->set('action', $form_state['values']['akamai_action'])
      ->set('email', $form_state['values']['akamai_email'])
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
ConfigFormBaseTrait::getEditableConfigNames abstract protected function Gets the configuration names that will be editable. 32
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormInterface::getFormId public function Returns a unique string identifying the form. 236
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
SettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
SettingsForm::getFormID public function
SettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
SettingsForm::validateForm public function Form validation handler. Overrides FormBase::validateForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.