You are here

function _search_exclude_reindex in Search Exclude (Node) 8

Same name and namespace in other branches
  1. 2.x search_exclude.module \_search_exclude_reindex()
  2. 2.0.x search_exclude.module \_search_exclude_reindex()

Find all active search_exclude plugins and trigger re-index of the entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

4 calls to _search_exclude_reindex()
search_exclude_comment_delete in ./search_exclude.module
Implements hook_ENTITY_TYPE_delete().
search_exclude_comment_insert in ./search_exclude.module
Implements hook_ENTITY_TYPE_insert().
search_exclude_comment_update in ./search_exclude.module
Implements hook_ENTITY_TYPE_update().
search_exclude_node_update in ./search_exclude.module
Implements hook_ENTITY_TYPE_update().

File

./search_exclude.module, line 49

Code

function _search_exclude_reindex(EntityInterface $entity) {

  /** @var SearchPageRepository $repo */
  $repo = \Drupal::service('search.search_page_repository');

  /** @var SearchPageInterface $item */
  foreach ($repo
    ->getIndexableSearchPages() as $item) {
    if ($item
      ->getPlugin()
      ->getPluginId() === 'search_exclude_node_search') {

      /** @var SearchExcludeNodeSearch $plugin */
      $plugin = $item
        ->getPlugin();
      $plugin
        ->reIndex($entity);
    }
  }
}