Problem/Motivation

Other modules which integrate with Webform could leverage Webform Share if hooks were provided at appropriate places in the process. The existing import can override the existing 'webform' property of the node object, but that may not be sufficient for modules which require other database tables to be updated for correct functioning. Adding a couple of hooks would eliminate that problem.

As you can probably guess, I'm working on a module that would benefit from such hooks. ;)

Proposed resolution

I suggest adding two hooks:

  1. hook_webform_share_import(&$node, $keep_existing_components)
  2. hook_webform_share_export_alter(&$node)

The hook_webform_share_export_alter() is probably of lesser importance, as other modules can get around it by hooks in webform itself, but that's much harder to do on import.

Remaining tasks

  1. Implement the hooks in the code
  2. Create a webform_share.api.php file to document the hooks

I would be happy to work up a patch to implement these hooks, if there is any interest in implementing them into the code.

User interface changes

None

API changes

Addition of the hooks specified above

Comments

dbcollies’s picture

Issue summary: View changes
alan d.’s picture

Status: Active » Needs review
StatusFileSize
new1.76 KB

Something like this?

dbcollies’s picture

Status: Needs review » Needs work

I actually got around this requirement in my module by hooking node load and save. So feel free to change this to "Closed (won't fix)" if you don't think it worth including.

However, if you still want to include this functionality, then I would suggest that the import hook be altered to include the flags set by the user. There should also be a webform_share.api.php file documenting the hooks. I'd be happy to submit an updated patch if you want.

alan d.’s picture

Sure, happy to commit if supplied.

dbcollies’s picture

Status: Needs work » Needs review
StatusFileSize
new4.04 KB

Here's my attempt at a new patch to do what I was describing.

alan d.’s picture

Status: Needs review » Fixed

You do not need the pointer reference (&) when passing an object, otherwise all good.

  • Alan D. committed 7b119c3 on 7.x-1.x
    git commit -m 'Issue #2306565 by dbcollies, Alan D.: Add hook on import...

Status: Fixed » Closed (fixed)

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