Verified Commit bc0673ec authored by godotislate's avatar godotislate
Browse files

task: #3581109 Move HelpSearch to Search sub-module

By: quietone
By: smustgrave
By: dcam
By: godotislate
parent 7a148275
Loading
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -14881,18 +14881,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\HelpSectionManager\\:\\:clearCachedDefinitions\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/HelpSectionManager.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\HelpSectionManager\\:\\:setSearchManager\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/HelpSectionManager.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\HelpTopicPluginBase\\:\\:getProvider\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -14905,42 +14893,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/HelpTopicTwigLoader.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:indexClear\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:markForReindex\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:removeItemsFromIndex\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:updateIndex\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:updateIndexState\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help\\\\Plugin\\\\Search\\\\HelpSearch\\:\\:updateTopicList\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/help/src/Plugin/Search/HelpSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\help_topics_twig_tester\\\\HelpTestTwigNodeVisitor\\:\\:setStateValue\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+0 −45
Original line number Diff line number Diff line
@@ -5,51 +5,6 @@
 * Install and uninstall functions for help module.
 */

/**
 * Implements hook_schema().
 */
function help_schema(): array {
  $schema['help_search_items'] = [
    'description' => 'Stores information about indexed help search items',
    'fields' => [
      'sid' => [
        'description' => 'Numeric index of this item in the search index',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'section_plugin_id' => [
        'description' => 'The help section the item comes from',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'permission' => [
        'description' => 'The permission needed to view this item',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'topic_id' => [
        'description' => 'The topic ID of the item',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
    ],
    'primary key' => ['sid'],
    'indexes' => [
      'section_plugin_id' => ['section_plugin_id'],
      'topic_id' => ['topic_id'],
    ],
  ];

  return $schema;
}

/**
 * Implements hook_update_last_removed().
 */
+0 −2
Original line number Diff line number Diff line
@@ -8,8 +8,6 @@ services:
  plugin.manager.help_section:
    class: Drupal\help\HelpSectionManager
    parent: default_plugin_manager
    calls:
      - [setSearchManager, ['@?plugin.manager.search']]
    tags:
      - { name: plugin_manager_cache_clear }
  help.breadcrumb:
+0 −34
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\help;

use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\help\Attribute\HelpSection;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -18,13 +17,6 @@
 */
class HelpSectionManager extends DefaultPluginManager {

  /**
   * The search manager.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface
   */
  protected ?PluginManagerInterface $searchManager = NULL;

  /**
   * Constructs a new HelpSectionManager.
   *
@@ -43,30 +35,4 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
    $this->setCacheBackend($cache_backend, 'help_section_plugins');
  }

  /**
   * Sets the search manager.
   *
   * @param \Drupal\Component\Plugin\PluginManagerInterface|null $search_manager
   *   The search manager if the Search module is installed.
   */
  public function setSearchManager(?PluginManagerInterface $search_manager = NULL) {
    $this->searchManager = $search_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function clearCachedDefinitions() {
    parent::clearCachedDefinitions();
    // Search module may be missing. Help module might be installing,
    // so its search plugin may not be discovered yet.
    if ($this->searchManager && $this->searchManager->hasDefinition('help_search')) {
      // Rebuild the index on cache clear so that new help topics are indexed
      // and any changes due to help topics edits or translation changes are
      // picked up.
      $help_search = $this->searchManager->createInstance('help_search');
      $help_search->markForReindex();
    }
  }

}
+0 −53
Original line number Diff line number Diff line
@@ -123,57 +123,4 @@ public function blockViewHelpBlockAlter(array &$build, BlockPluginInterface $blo
    unset($build['#contextual_links']);
  }

  /**
   * Implements hook_modules_uninstalled().
   */
  #[Hook('modules_uninstalled')]
  public function modulesUninstalled(array $modules): void {
    $this->searchUpdate($modules);
  }

  /**
   * Implements hook_modules_installed().
   */
  #[Hook('modules_installed')]
  public function modulesInstalled(array $modules, $is_syncing): void {
    $this->searchUpdate();
  }

  /**
   * Implements hook_themes_installed().
   *
   * Implements hook_themes_uninstalled().
   */
  #[Hook('themes_installed')]
  #[Hook('themes_uninstalled')]
  public function themesInstallOrUninstall(array $themes): void {
    \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
    $this->searchUpdate();
  }

  /**
   * Ensure that search is updated when extensions are installed or uninstalled.
   *
   * @param string[] $extensions
   *   (optional) If modules are being uninstalled, the names of the modules
   *   being uninstalled. For themes being installed/uninstalled, or modules
   *   being installed, omit this parameter.
   */
  protected function searchUpdate(array $extensions = []): void {
    // Early return if search is not installed or if we're uninstalling this
    // module.
    if (
      !\Drupal::hasService('plugin.manager.search') ||
      in_array('help', $extensions)
    ) {
      return;
    }

    // Ensure that topics for extensions that have been uninstalled are removed
    // and that the index state variable is updated.
    $help_search = \Drupal::service('plugin.manager.search')->createInstance('help_search');
    $help_search->updateTopicList();
    $help_search->updateIndexState();
  }

}
Loading