You are here

public function ResourceHintsConfigForm::submitForm in Resource Hints 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/ResourceHintsConfigForm.php, line 153

Class

ResourceHintsConfigForm
Configure resource hints for this site.

Namespace

Drupal\resource_hints\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $dns_prefetch_resources = explode(PHP_EOL, $form_state
    ->getValue('dns_prefetch_resources'));
  $preconnect_resources = explode(PHP_EOL, $form_state
    ->getValue('preconnect_resources'));
  $prefetch_resources = explode(PHP_EOL, $form_state
    ->getValue('prefetch_resources'));
  $prerender_resources = explode(PHP_EOL, $form_state
    ->getValue('prerender_resources'));
  $config = \Drupal::service('config.factory')
    ->getEditable('resource_hints.settings');
  $config
    ->set('dns_prefetch_resources', $dns_prefetch_resources)
    ->set('dns_prefetch_output', $form_state
    ->getValue('dns_prefetch_output'))
    ->set('dns_prefetch_control', $form_state
    ->getValue('dns_prefetch_control'))
    ->set('preconnect_resources', $preconnect_resources)
    ->set('preconnect_output', $form_state
    ->getValue('preconnect_output'))
    ->set('prefetch_resources', $prefetch_resources)
    ->set('prefetch_output', $form_state
    ->getValue('prefetch_output'))
    ->set('prerender_resources', $prerender_resources)
    ->set('prerender_output', $form_state
    ->getValue('prerender_output'))
    ->save();
  parent::submitForm($form, $form_state);
}