You are here

public function SocialProfileSettingsForm::submitForm in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  2. 8 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  3. 8.2 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  4. 8.3 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  5. 8.4 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  6. 8.5 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  7. 8.6 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  8. 8.7 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  9. 8.8 modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  10. 10.3.x modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  11. 10.0.x modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::submitForm()
  12. 10.1.x modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php \Drupal\social_profile\Form\SocialProfileSettingsForm::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 ConfigFormBase::submitForm

File

modules/social_features/social_profile/src/Form/SocialProfileSettingsForm.php, line 162

Class

SocialProfileSettingsForm
Configure social profile settings.

Namespace

Drupal\social_profile\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Save config.
  $config = $this
    ->config('social_profile.settings');
  $config
    ->set('social_profile_show_email', $form_state
    ->getValue('social_profile_show_email'));
  $config
    ->set('enable_profile_tagging', $form_state
    ->getValue('enable_profile_tagging'));
  $config
    ->set('allow_category_split', $form_state
    ->getValue('allow_category_split'));
  $config
    ->set('use_category_parent', $form_state
    ->getValue('use_category_parent'));
  $config
    ->set('allow_tagging_for_lu', $form_state
    ->getValue('allow_tagging_for_lu'));
  $config
    ->save();

  // Check if the website is multilingual.
  if ($this->languageMananger
    ->isMultilingual()) {
    $config
      ->set('social_profile_show_language', $form_state
      ->getValue('social_profile_show_language'))
      ->save();
  }

  // Invalidate profile cache tags.
  $query = $this->database
    ->select('profile', 'p');
  $query
    ->addField('p', 'profile_id');
  $query
    ->condition('p.type', 'profile');
  $query
    ->condition('p.status', '1');
  $ids = $query
    ->execute()
    ->fetchCol();
  if (!empty($ids)) {
    $cache_tags = [];
    foreach ($ids as $id) {
      $cache_tags[] = 'profile:' . $id;
    }
    Cache::invalidateTags($cache_tags);
  }
  parent::submitForm($form, $form_state);
}