Update all plugin alter hook definitions to provide an example of how to modify the plugin class

Created on 9 June 2014, over 10 years ago
Updated 10 August 2024, 4 months ago

I was told on #2087965: The SearchPluginManager needs to provide an alter hook for its discovery β†’ that this plugin documentation header provides sufficient information for someone who wants to implement the hook, and that it is the standard way to document plugin alter hooks:

/**
 * Alter search plugin definitions.
 *
 * @param array $definitions
 *   The array of search plugin definitions, keyed by plugin ID.
 *
 * @see \Drupal\search\Annotation\SearchPlugin
 * @see \Drupal\search\SearchPluginManager
 */
function hook_search_plugin_alter(array &$definitions) {
  if (isset($definitions['node_search'])) {
    $definitions['node_search']['title'] = t('Nodes');
  }
}

Apparently, the main reason that someone would want to use one of these plugin hooks is to substitute their own class for one of the Core (or other module) plugins. It was not obvious to me how you would do this, from this documentation header.

I think it should be made more obvious. Specifically:
a) The sample function body should illustrate the usual reason someone would want to alter the plugin definition, not an atypical case like altering the title.
b) The @param should explain where to find documentation about what the "array of search plugin definitions" is (what each search definition is, which is an array of objects? arrays? who knows).

And this needs to be done for all of the plugin alter hooks, not just Search, because apparently this is the typical documentation being used for all the plugins.

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
DocumentationΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States jhodgdon Spokane, WA, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024