You are here

public function FooterSettingsForm::submitForm in Open Social 10.3.x

Same name and namespace in other branches
  1. 10.0.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::submitForm()
  2. 10.1.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::submitForm()
  3. 10.2.x modules/social_features/social_footer/src/Form/FooterSettingsForm.php \Drupal\social_footer\Form\FooterSettingsForm::submitForm()

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 FormInterface::submitForm

File

modules/social_features/social_footer/src/Form/FooterSettingsForm.php, line 106

Class

FooterSettingsForm
Creates a form for configuring footer block.

Namespace

Drupal\social_footer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $logo = '';
  $values = $form_state
    ->getValues();
  if ($values['logo'] = $form_state
    ->getValue('logo')) {

    /** @var \Drupal\file\FileInterface $file */
    $file = $this->fileStorage
      ->load($logo = $values['logo'][0]);
    $file
      ->setPermanent();
    $file
      ->save();
  }
  $block = self::configFactory()
    ->getEditable('block.block.socialblue_footer_powered');
  if ($block) {
    $settings = $block
      ->get('settings');
    $settings['logo'] = $logo;
    $settings['text'] = $values['text'];
    $settings['link']['url'] = $values['url'];
    $settings['link']['title'] = $values['title'];
    $block
      ->set('settings', $settings)
      ->save();
  }
  $this
    ->messenger()
    ->addStatus(t('Your footer settings have been updated'));
}