Problem/Motivation

Due to the specification of my client task, I was required to include the name of the CRUD operation (eg. create, update, delete, etc.) in the notification content. To allow all my @ChannelPlugin instances leverage by consuming this piece of information I thought it might be best to introduce an extra [push-object:topic] Token which could be used in the notification templates.

Proposed resolution

So here's my initial approach which definitely needs some pairs of more experienced eyes to make it more elegant. This is my very first token definition ever written so please share your suggestions on how to improve it.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Balu Ertl created an issue. See original summary.

baluertl’s picture

Assigned: baluertl » Unassigned
Status: Active » Needs review
jurgenhaas’s picture

Status: Needs review » Needs work

Thanks @Balu Ertl for your contribution, this is great to see.

The approach in the MR is problematic because DANSE is not a dependency for the push framework. Instead, this token should be provided by the DANSE module.

jurgenhaas’s picture

BTW, we are integrating both modules (DANSE and Push Framework) with ECA. That way, you could handle all such cases there without having to have any custom code. See #3325561: Integrate with ECA. Just saying, we could still also add some hooks as suggested but maybe that no longer required then, because we would have events available to which you could subscribe.

jurgenhaas’s picture

Status: Needs work » Needs review
Related issues: +#3328626: Provide tokens for notifications

I've now implemented a different approach for this: when the SourceItem calls prepareContent from the channel plugin, it forwards the source plugin and the source id, and while preparing the content, those two arguments are forwarded as token data called push_framework_source_plugin and push_framework_source_id to the token replace function.

This way, we are completely generic, regardless from where the data is coming that's being pushed.

The source of the push notification, in your case DANSE, can then implement some tokens that will be able to load the notification by using the provided data and use that to replace them. This will be addressed in #3328626: Provide tokens for notifications.

jurgenhaas’s picture

Title: Make CRUD operation available as token » Let source plugins inject tokens to pushed content

Changing title.

danielspeicher’s picture

Status: Needs review » Reviewed & tested by the community

Cool stuff.

Concerning the code comment convention, I propose to do this all in the cleanup ticket. Like we did in ECA.

  • jurgenhaas committed 2e20591b on 2.2.x
    Issue #3324587 by Balu Ertl, jurgenhaas, danielspeicher: Let source...
jurgenhaas’s picture

Status: Reviewed & tested by the community » Fixed

Excellent

  • jurgenhaas committed af1fef2a on 2.2.x
    Issue #3324587 by Balu Ertl, jurgenhaas: Make CRUD operation available...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.