Add a tag to spool storage query

Created on 6 June 2024, 10 months ago

Problem/Motivation

When the spool storage is getting the emails to send, there is no way to modify the the list of email to get according custom rules.
But it could be interesting to expose the query in order to allow a developer altering the list of emails on the fly for some contextuals reasons or identified rules.
In my particular case I have to reorder the email sending list following a strict priority list of email stored in a dedicated field.
In this specific example I would like to alter the query in this way :

$query->leftJoin('simplenews_subscriber__field_priority', 'priority', '[s].[snid] = [priority].[entity_id]');
$query->orderBy('priority.field_priority_value', 'DESC');

Proposed resolution

Adding a tag to the select query (for example simplenews_mail_spool) could allow another module to override the email select query as his need.

API changes

/**
 * Implements hook_query_TAG_alter().
 */
function hook_query_simplenews_mail_spool_alter(AlterableInterface $query) {
  $query->leftJoin('simplenews_subscriber__field_priority', 'priority', '[s].[snid] = [priority].[entity_id]');
  $query->orderBy('priority.field_priority_value', 'DESC');
}
Feature request
Status

Active

Version

4.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024