function _search_api_saved_searches_adapt_mail in Search API Saved Searches 8
Updates a user's saved searches to reflect a changed mail address.
Only used for searches that use the "E-Mail" notification plugin.
Parameters
\Drupal\user\UserInterface $account: The user account in question.
\Drupal\user\UserInterface $original: The old version of the user account, with the old mail address.
1 call to _search_api_saved_searches_adapt_mail()
- search_api_saved_searches_user_update in ./
search_api_saved_searches.module - Implements hook_ENTITY_TYPE_update() for type "user".
File
- ./
search_api_saved_searches.module, line 212 - Allows visitors to bookmark searches and get notifications for new results.
Code
function _search_api_saved_searches_adapt_mail(UserInterface $account, UserInterface $original) {
$searches = _search_api_saved_searches_load_searches($account
->id(), $original
->getEmail());
/** @var \Drupal\search_api_saved_searches\Entity\SavedSearch $search */
foreach ($searches as $search) {
$search
->set('mail', $account
->getEmail());
try {
$search
->save();
} catch (EntityStorageException $e) {
$args['@search_id'] = $search
->id();
watchdog_exception('search_api_saved_searches', $e, '%type while trying to save saved search #@search_id: @message in %function (line %line of %file).', $args);
}
}
}