- Issue created by @vensires
- 🇬🇷Greece vensires
In MR!39, I went on with the second proposed solution and introduced
hook_search_api_autocomplete_suggester_item_url_alter()
.Feel free to change the hook's name if you desire it; I tried to avoid using the "live_results" name somehow in case it's used somewhere else in the future too.
- 🇦🇹Austria drunken monkey Vienna, Austria
drunken monkey → made their first commit to this issue’s fork.
- Merge request !40Refactor LiveResults to have a separate getItemUrl() method for easier overriding → (Open) created by drunken monkey
- 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for suggesting this improvement!
You are right that I’d say adding explicit support for Paragraph entities would be a bit too specific a solution for my taste. So, making this easier for custom code to fix on its own seems like the better approach.I wanted to comment and say that we’ve moved to using events instead of hooks and to please create one of those instead – however, I then realized that we haven’t actually made that move in this module. I created 📌 Convert all hooks to events Active for that – in case this gets merged, we’d just have to port one more hook to an event. (Though it seems less than ideal to introduce a new hook and then perhaps deprecate it a few weeks later.)
However, introducing a new hook for that also seems like a bit of an overkill, at least unless more people express interest in this functionality.
A simpler approach would be to extract the$datasource->getItemUrl($object)
call into its own method on theLiveResults
suggester – that way, you could simply change the plugin’s class to a custom subclass where you override that method.
Would that also work? It seems to me like that would be a less invasive solution to the problem, even though a bit more custom code would be needed as a downside. - 🇬🇷Greece vensires
@drunken-monkey thank you for your really detailed response!
I wasn't aware of 📌 Convert all hooks to events Active ; you are correct though that it would be better not to introduce a hook and then deprecate it. We could have this as an event directly instead. This way it would be ready for merging.
I had already thought of overriding the original $datasource's class or the
LiveResults
class usinghook_search_api_autocomplete_search_info_alter(&$info) {...}
but it really was too much of a code to be duplicated just for this change. Your proposal from MR!40 is much simpler and future-proof. Let's go on with this one then.PS: I also update the issue summary with your solution.