Let modules to alter query before channel request is made to the server.

Created on 14 July 2022, over 2 years ago
Updated 16 February 2023, almost 2 years ago

Problem/Motivation

In some cases you want to enhance the UI of entity share entity listing page after channel is selected, by adding some additional AND jsonapi filters, form selects.
Yes, we have SEARCHES on server channel config, that we can use for this purpose, however searches will enforce OR jsonapi group along with with entity label search, which is not always useful.

Proposed resolution

Add alter hook to give installed modules a chance to modify $parsed_url query before channel request is made to the server, as well as $form and $form_state.

Remaining tasks

Add documentation for api hook alter.

✨ Feature request
Status

Needs work

Version

3.0

Component

Entity share client

Created by

πŸ‡ΊπŸ‡¦Ukraine taras.suliatitskiy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    Thanks for your feature request and the work done in it.

    But instead of hooks, can you please dispatch events.

    I avoid to introduce new hooks as much as possible in favor of events.

    I also put some review comments in the MR.

  • πŸ‡ΊπŸ‡ΈUnited States dgroene

    I committed and pushed changes to swap the hooks for events, but not figuring out how to make it mergeable.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States dgroene
  • πŸ‡ΊπŸ‡ΈUnited States dgroene

    Patch against RC-4 for someone who might need it.

  • πŸ‡ΊπŸ‡ΈUnited States dgroene
  • πŸ‡ΊπŸ‡ΈUnited States dgroene
  • Assigned to Grimreaper
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·
  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    Once again thanks for your work on that.

    Only two questions remaining.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States dgroene
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    @dgroene, thanks a lot to have updated the MR!

    It looks ok.

    But I want to give it a longer look and have limited time for now and priority is to release a stable release.

    Also now that 4.0.x branch exists, I will have to cherry-pick it.

    So I keep this issue for later.

    I wonder if the events should be introduced at the pull form level or deeper into the import Service to be also available to CLI usage?

    Also needs to create change record for the 2 new events introduced.

  • πŸ‡ΊπŸ‡ΈUnited States dgroene

    I am fine with whichever you prefer. For me, this is all about altering the pull form to add additional information for the content editors to see what they are pulling- the additions to the jsonapi query go hand in hand with altering the pull form. I have not used it with the CLI.

  • Hi, this looks like the feature I need for my issue πŸ’¬ Share entities based on client Active

    What would be the steps to use this? Do I just patch the module with #15?

    Is there a current way to add a filter to the $prepared_url in the entity_share/modules/entity_share_client/src/Form/PullForm.php?

    I could create a custom module but would need a pointer on how to go about hooking into the PullForm please

    or, can we release this?

  • Status changed to RTBC 5 months ago
  • Hi,

    I have tested the MR against the 8.x-3.0 branch and was able to create a custom module that subscribes to the event dispatched from this code (JsonApiQueryEvent).

    It was then successful in altering the query before the channel request was sent, and able to filter the json results by specifying additional filters from the client side (same filters that can be found in the 'collections' section of the Json API extras).

    Would be great if we could release this please :)

    Thanks

  • πŸ‡¨πŸ‡¦Canada chemeon

    Also tested the MR against 8.x-3.0 branch and was able to add additional query filtering on the JsonApiQueryEvent, which was successful in returning the appropriate entities on the Pull Form.

    Would like this to be able to be extended past the Pull Form/ implemented in the Import Service as suggested in #19 so submodules like Entity Share Cron can also make use of the JsonApiQueryEvent to allow users to implement the same altered filtering on cron.

Production build 0.71.5 2024