You are here

public function SocialProfileFieldsSettingsForm::submitForm in Open Social 8.4

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

Class

SocialProfileFieldsSettingsForm
Configure social profile settings.

Namespace

Drupal\social_profile_fields\Form

Code

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

  // Save config.
  $config = $this
    ->config('social_profile_fields.settings');

  /** @var \Drupal\profile\Entity\ProfileType $profile_type */
  foreach (ProfileType::loadMultiple() as $profile_type) {
    $type = $profile_type
      ->id();

    /** @var \Drupal\field\Entity\FieldConfig $field_config */
    foreach ($this->profileFieldsHelper
      ->getProfileFields($type) as $field) {
      $config
        ->set($field['id'], $form_state
        ->getValue($field['id']));
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);

  // 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();
  $cache_tags = [
    'profile',
    'profile_list',
    'profile_view',
  ];
  if (!empty($ids)) {
    foreach ($ids as $id) {
      $cache_tags[] = 'profile:' . $id;
    }
  }
  $this->cacheTagsInvalidator
    ->invalidateTags($cache_tags);

  // If the user export module is on, clear the cached definitions.
  if ($this->moduleHandler
    ->moduleExists('social_user_export')) {
    $user_export_manager = \Drupal::service('plugin.manager.user_export_plugin');
    $user_export_manager
      ->clearCachedDefinitions();
  }
}