As the functionality of the Salesforce Web-to-Lead Webform Data Integration module has been moved into a webform handler, there now exists the possibility for the data to be passed to multiple salesforce accounts/data stores.
The existing hook, hook_sfweb2lead_webform_posted_data_alter()
, works well for only one instance of the handler but control over per handler data changes is not possible.
To increase the flexibility of the module, another hook could be added that has the handler passed in.
Comment | File | Size | Author |
---|---|---|---|
#8 | sfweb2lead_webform-add-data-alter-hook-2982152-8.patch | 5.15 KB | nginex |
#8 | interdiff_4-8.txt | 1.76 KB | nginex |
#2 | 2982152-1.patch | 1.88 KB | John Cook |
#4 | 2982152-4.patch | 5.22 KB | John Cook |
Comments
Comment #2
John Cook CreditAttribution: John Cook at Creode commentedI've created a new alter hook –
hook_sfweb2lead_webform_handler_data_alter()
.This hook has the data array, current handler, and the webform submission passed in.
This allows for the handler's configuration to be accessed and decisions to how the data is to be altered can be made from this information.
It may also be possible to deprecate the
hook_sfweb2lead_webform_posted_data_alter()
hook as the webform object can be obtained from the handler.Comment #3
AaronBaumanThis is a good idea.
Some feedback:
1) seems a bit silly to have both those in succession, though i understand the instinct to preserve existing functionality. Let's mark the existing hook deprecated, and to be removed in 5.0 stable release. And let's fire a watchdog error for anyone still using it, so they know to replace their impelmentations.
2) let's replace it with an event dispatcher, instead of a hook. Let me know if you want help on figuring what that event should look like.
Comment #4
John Cook CreditAttribution: John Cook at Creode commentedI've made a start at re-implementing this functionality as an event.
There's a new event,
Sfweb2leadWebformEvent
, that a subscriber can listen for. The existing hook functionality has also been wrapped in a subscriber for consistency.There's a bit of type wrangling to try and make it easier with passing the submission data around.
There's no interdiff because this is essentially a new patch from master.
There's a bit of tidying up that needs to be done – mainly comments – so it's not ready for a proper review yet.
I'm adding the 'novice' tag for creating/updating the comments.
Comment #5
AaronBaumanLooks good so far.
A couple minor points real quick:
There's no reason to cast $salesforce_data to an object, then back.
It's a property of Sfweb2leadWebformEvent, which will be passed by reference - expose it via setter(s) instead:
And add a typehint to the constructor like so:
+ public function __construct(array $data, SalesforceWebToLeadPostWebformHandler $handler, WebformSubmissionInterface $submission) {
Comment #6
nginex CreditAttribution: nginex at Drupal Ukraine Community commentedComment #7
nginex CreditAttribution: nginex at Drupal Ukraine Community commentedI'm going to fix the above minor points.
Comment #8
nginex CreditAttribution: nginex at Drupal Ukraine Community commentedHere we go
Comment #9
nginex CreditAttribution: nginex at Drupal Ukraine Community commentedComment #11
AaronBaumanThanks for the patch. I've committed a slightly updated version.