search.post_update.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * @file
  4. * Post update functions for Search module.
  5. */
  6. use Drupal\block\BlockInterface;
  7. use Drupal\Core\Config\Entity\ConfigEntityUpdater;
  8. /**
  9. * Configures default search page for instantiated blocks.
  10. */
  11. function search_post_update_block_page(&$sandbox = NULL) {
  12. if (!\Drupal::moduleHandler()->moduleExists('block')) {
  13. // Early exit when block module disabled.
  14. return;
  15. }
  16. \Drupal::classResolver(ConfigEntityUpdater::class)
  17. ->update($sandbox, 'block', function (BlockInterface $block) {
  18. // Save search block to set default search page from plugin.
  19. return $block->getPluginId() === 'search_form_block';
  20. });
  21. }
  22. /**
  23. * Mark everything for reindexing after diacritics removal rule change.
  24. */
  25. function search_post_update_reindex_after_diacritics_rule_change() {
  26. $search_page_repository = \Drupal::service('search.search_page_repository');
  27. foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
  28. $entity->getPlugin()->markForReindex();
  29. }
  30. return t("Content has been marked for re-indexing for all active search pages. Searching will continue to work, but new content won't be indexed until all existing content has been re-indexed.");
  31. }