I understand the reasons why this module avoids the synchronization of user and config entities. However, there should be an entry point for custom code to fill this information when needed. For example, depending on the adopted solution, a user can be linked to the entity by just checking the username as it might have already been pulled by some SSO mechanism.
Thus, I suggest that a hook is provided allowing third-party modules to change the imported entity before it is saved. It differs from hook_entity_presave() as the decoded JSON response would be passed to the hook implementation along with the entity object. I also recommend passing along an HTTP client configured for the remote to allow modules to get more information about the referenced entities, like the username. Another option would be passing the JsonapiHelper object, but its getHttpClient()
method is protected.
Inspecting the code, I think the changes should be made to the Drupal\entity_share_client\Service\JsonapiHelper::importEntityListData()
method.
I could try to provide a patch for this.
Comment | File | Size | Author |
---|---|---|---|
#8 | entity_share-event_alter-3003823-8.patch | 9.77 KB | Grimreaper |
#8 | interdiff-3003823-7-8.txt | 9.21 KB | Grimreaper |
#7 | event-to-alter-imported-entities-3003823-7.patch | 8.13 KB | msti |
#6 | event-to-alter-imported-entities-3003823-5.patch | 7.69 KB | msti |
#4 | event-to-alter-imported-entities-3003823-4.patch | 11.73 KB | msti |
Comments
Comment #2
dbiscalchin CreditAttribution: dbiscalchin commentedComment #3
GrimreaperHello,
Thanks for your interest in the module and your suggestion.
Instead of a hook, it would be better to add an event.
Comment #4
mstiHi,
This patch adds 3 Events. It allows the developers to alter the entity at 3 stages:
Comment #5
mstiComment #6
mstiThis is the correct patch
Comment #7
mstianother fix
Comment #8
GrimreaperHello,
For #3064331: Compatibility with block field, I had to add event.
So I will merge the patch. Attached is a new patch taken from 7.
Remove changes in Remote.php and change an event name and fixes CS.
Waiting for automated tests results before merging.
Also warning, MAYBE during rework in #3060694: Rework service and tests some changes will occur to events.
Comment #9
GrimreaperComment #11
GrimreaperMerged!
Thanks for your contribution!