Add example module with event subscriber

Created on 10 January 2019, almost 6 years ago
Updated 11 June 2024, 6 months ago

Problem/Motivation

In order to alter the query, you either have to override the SearchBuilder class and replace large swaths of code, or you have to create an event listener. Once an event listener is created, it's pretty easy to alter the query, but creating it is time consuming for developers. It would be great if there were an example module with an example event subscriber that could be copied into your custom module and adjusted.

Alternatively, adding drupal alter hooks and api documentation would help. See #2947799: Allow for custom modules alterations β†’

Proposed resolution

Option 1) Add a submodule elasticsearch_connector_example_event_subscriber that has an example for each of the events the module offers

Option 2) Add alter hooks for each of the events so that those users who want to alter the SearchBuilder can without the lift of writing their own event subscribers. An elasticsearch_connector.api.php file would document each hook. #2947799: Allow for custom modules alterations β†’

✨ Feature request
Status

Needs review

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area

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.

  • πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

    This is sorely needed, and the hooks are currently issuing deprecation warnings.

    I would ask whether we should include the Search API events in the examples as well? Though this might be something better suited in the Search API module. I am noticing a trend where procedural hooks are still documented in *.api.php files, but newer plugins don't seem to have any clear documentation of their own.

    I'm currently looking at a "search_api.query_pre_execute" event. which does give me the search api query, but I seem to be struggling to add any custom functionality via this means. I'd suggest having these hooks perform some small alteration examples as well, since I'm struggling to find any other simple documentation in this.

Production build 0.71.5 2024