function SearchHooks::cron

Implements hook_cron().

Fires updateIndex() in the plugins for all indexable active search pages, and cleans up dirty words.

File

core/modules/search/src/Hook/SearchHooks.php, line 95

Class

SearchHooks
Hook implementations for search.

Namespace

Drupal\search\Hook

Code

public function cron() {
    
    /** @var \Drupal\search\SearchPageRepositoryInterface $search_page_repository */
    $search_page_repository = \Drupal::service('search.search_page_repository');
    foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
        $entity->getPlugin()
            ->updateIndex();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.