search_exclude.module in Search Exclude (Node) 8
Same filename and directory in other branches
File
search_exclude.moduleView source
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\search\SearchPageInterface;
use Drupal\search\SearchPageRepository;
use Drupal\search_exclude\Plugin\Search\SearchExcludeNodeSearch;
/**
* Implements hook_ENTITY_TYPE_update().
*
* Triggers the reindex for node updates.
*/
function search_exclude_node_update(EntityInterface $entity) {
_search_exclude_reindex($entity);
}
/**
* Implements hook_ENTITY_TYPE_insert().
*
* Triggers the reindex for comment insert.
*/
function search_exclude_comment_insert(EntityInterface $comment) {
_search_exclude_reindex($comment);
}
/**
* Implements hook_ENTITY_TYPE_update().
*
* Triggers the reindex for comment update.
*/
function search_exclude_comment_update(EntityInterface $comment) {
_search_exclude_reindex($comment);
}
/**
* Implements hook_ENTITY_TYPE_delete().
*
* Triggers the reindex for comment updates.
*/
function search_exclude_comment_delete(EntityInterface $comment) {
_search_exclude_reindex($comment);
}
/**
* Find all active search_exclude plugins and trigger re-index of the entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
*/
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);
}
}
}
Functions
Name | Description |
---|---|
search_exclude_comment_delete | Implements hook_ENTITY_TYPE_delete(). |
search_exclude_comment_insert | Implements hook_ENTITY_TYPE_insert(). |
search_exclude_comment_update | Implements hook_ENTITY_TYPE_update(). |
search_exclude_node_update | Implements hook_ENTITY_TYPE_update(). |
_search_exclude_reindex | Find all active search_exclude plugins and trigger re-index of the entity. |