You are here

function _search_api_saved_searches_deactivate_searches in Search API Saved Searches 8

Deactivates all saved searches for a specific user account.

Parameters

\Drupal\user\UserInterface $account: The user account in question.

1 call to _search_api_saved_searches_deactivate_searches()
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 187
Allows visitors to bookmark searches and get notifications for new results.

Code

function _search_api_saved_searches_deactivate_searches(UserInterface $account) {
  $searches = _search_api_saved_searches_load_searches($account
    ->id());

  /** @var \Drupal\search_api_saved_searches\SavedSearchInterface $search */
  foreach ($searches as $search) {
    $search
      ->set('notify_interval', -1);
    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);
    }
  }
}