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.
Issue fork push_framework-3324587
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:
- 3324587-make-crud-operation
changes, plain diff MR !4
- 2.2.x
changes, plain diff MR !1
Comments
Comment #3
baluertlComment #4
jurgenhaasThanks @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.
Comment #5
jurgenhaasBTW, 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.
Comment #8
jurgenhaasI've now implemented a different approach for this: when the
SourceItemcallsprepareContentfrom 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 calledpush_framework_source_pluginandpush_framework_source_idto 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.
Comment #9
jurgenhaasChanging title.
Comment #10
danielspeicher commentedCool stuff.
Concerning the code comment convention, I propose to do this all in the cleanup ticket. Like we did in ECA.
Comment #12
jurgenhaasExcellent