public function SocialProfileFieldsSettingsForm::submitForm in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.2 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.3 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.4 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.5 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.6 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.7 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 8.8 modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 10.3.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 10.0.x modules/social_features/social_profile/modules/social_profile_fields/src/Form/SocialProfileFieldsSettingsForm.php \Drupal\social_profile_fields\Form\SocialProfileFieldsSettingsForm::submitForm()
- 10.1.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 245
Class
- SocialProfileFieldsSettingsForm
- Configure social profile settings.
Namespace
Drupal\social_profile_fields\FormCode
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']));
}
}
$main_address_value = $form_state
->getValue('profile_profile_field_profile_address');
$config
->set('profile_address_field_city', $main_address_value ? $form_state
->getValue('profile_address_field_city') : FALSE);
$config
->set('profile_address_field_address', $main_address_value ? $form_state
->getValue('profile_address_field_address') : FALSE);
$config
->set('profile_address_field_postalcode', $main_address_value ? $form_state
->getValue('profile_address_field_postalcode') : FALSE);
$config
->set('profile_address_field_administrative_area', $main_address_value ? $form_state
->getValue('profile_address_field_administrative_area') : FALSE);
$config
->set('nickname_unique_validation', $form_state
->getValue('nickname_unique_validation'));
$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);
// Clear the entity type manager cached definitions as the nick name unique
// validation might now need to be applied.
// @see social_profile_fields_entity_bundle_field_info_alter().
$this->entityTypeManager
->clearCachedDefinitions();
// Clear the entity field manager cached field definitions as the address
// field overrides settings need to be applied.
// @see social_profile_fields_entity_bundle_field_info_alter().
$this->entityFieldManager
->clearCachedFieldDefinitions();
// 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();
}
}