function _social_profile_privacy_resave_search_indexes in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
- 8.7 modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
- 10.3.x modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
- 10.0.x modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
- 10.1.x modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
- 10.2.x modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module \_social_profile_privacy_resave_search_indexes()
Re-saves search indices.
This triggers the save for search indices that have profile entities as data. This ensures that the RestrictedNameProcessor is properly added.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
2 calls to _social_profile_privacy_resave_search_indexes()
- social_profile_privacy_install in modules/
social_features/ social_profile/ modules/ social_profile_privacy/ social_profile_privacy.install - Implements hook_install().
- social_profile_privacy_post_update_8001_restricted_name_field in modules/
social_features/ social_profile/ modules/ social_profile_privacy/ social_profile_privacy.post_update.php - Re-save the All and Users indices to add restricted name field.
File
- modules/
social_features/ social_profile/ modules/ social_profile_privacy/ social_profile_privacy.module, line 508 - The Social profile privacy module file.
Code
function _social_profile_privacy_resave_search_indexes() {
// If the search api module is not installed we have nothing to do.
if (!\Drupal::moduleHandler()
->moduleExists('search_api')) {
return;
}
// We load all indexes, we assume there will never be hundreds of search
// indexes which would create its own problems for a site.
$indexes = \Drupal::entityTypeManager()
->getStorage('search_api_index')
->loadMultiple();
/** @var \Drupal\search_api\IndexInterface $index */
foreach ($indexes as $index) {
// Check if the search index has profile entities as data source.
if ($index
->isValidDatasource('entity:profile')) {
// Disable and enable the index to ensure that the RestrictedNameProcessor
// has the chance to add the field.
$index
->save();
}
}
}