The DeleteHandler does not dispatch useful events that are analogs to the other pull-related events PULL_PREPULL and PULL_ENTITY_VALUE. It would be helpful to have such an event, and the ability to prevent the delete from completing.
Use cases would include unpublishing blocks when their object is delete from Salesforce, and blocking a user (for example block a user that owns content instead of deleting the user and reassigning the content) instead of deleting them.
Probably only one would be needed, but until #3065207: Allow modules to prevent the entities's data records from being deleted lands in core it is hard to have modules prevent an entity from being deleted during sync when under some project specific set of conditions, and even with that update to core there are likely times it makes more sense to handle preventing deleting in the context of the SF Suite events then core events.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | add_delete_allowed_event-3090974-6.patch | 4.48 KB | acrosman |
Comments
Comment #2
aaronbaumanYeah, this makes sense to me, unfortunately.
I have wanted to use core entity hooks whenever possible, but increasingly it seems like they're not sufficient to inject biz logic where we need it.
Comment #3
acrosmanSince you're on board with the concept and all the patterns and plumbing look to be in place already I will try to toss together at least an initial patch in the next couple days.
Comment #4
acrosmanHere is a first pass. Largely untested, and it needs formal test code anyway, but it's a start.
This is based on the
SalesforcePushAllowedEventevent, and I tried to follow that design pattern so it is in keeping with the other elements of the module. The new event isSalesforceDeleteAllowedEventand is triggered fromDeleteHandlerinsalesforce_pull.Comment #5
acrosmanThat's embarrassing. Let's try that again...
Comment #6
acrosmanExisting tests now pass in my local environment. Still needs tests for the new event, but I don't see a sample test for PullAllowed. If there is a pattern for this kind of event test around I'd love to see it.
Comment #7
acrosmanComment #9
aaronbaumanThis is in.