search.post_update.php 657 B

123456789101112131415161718192021222324
  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. }