Allow easier altering of entity query

Created on 28 January 2024, 5 months ago
Updated 29 January 2024, 5 months ago

Problem/Motivation

It's a bit painful using hook_query_TAG_alter() as you don't have access to the entity query.

Proposed resolution

Add events to allow modules to alter the query earlier (while keeping the query tag alter for situations where it's needed).

API changes

  1. There's a new event \Drupal\prevnext\Event\QueryEvent:
    1. You can use it to prevent prevnext from adding the entity ID condition and sort to the query (eg. you're using a date field instead).
    2. You can use it to completely replace the query used, in which case you take responsibility for access checks, language, etc.
  2. There's a new event \Drupal\prevnext\Event\QueryEventAlter that can be used to alter the entity query (without replacing the normal prevnext conditions, and sort).
✨ Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom AndyF

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024