New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements #4453: entities/river queries alterable by hooks (WIP) #6256
Conversation
'subject_guid' => $entity->guid, | ||
'object_guid' => $entity->guid, | ||
); | ||
$id = elgg_create_river_item($params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love it if we checked if general get river actually finds this one first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit should make this clearer
We must create some kind of a guideline for naming the queries. There's not much use for the hooks if the names given by plugin devs aren't context-aware and unique enough. |
I think these patterns would cover most of the built-in queries we'd want to make modifiable
|
Maybe we should remove |
+1 On Sunday, February 9, 2014, Juho Jaakkola notifications@github.com wrote:
Evan Winslow |
|
This adds support for the option "query_name" in elgg_get_entities, elgg_get_river, and elgg_get_annotations. The option causes the $options array to be filtered by a plugin hook before the function executes the query. Most core listings are also given query names, allowing devs to alter built-in queries without overriding core systems. Refs: Elgg#4453
Updated to simplify unit tests, improve phpdocs, add RST docs, and to give names to a ton of core listings, including the custom index, group modules, and some sidebar listings. One thing we probably need to clarify here is that the $options used in core pages are subject to change, and these changes may break complex alterations via hook. In essence these currently internal queries sort of become API surface. I think, though, the users of these APIs will typically be more savvy devs. Anyway, this adds more named queries than I was projecting earlier but the RST docs should document them all. |
BTW the query_name APIs are tested, but I had to test the page listings manually to verify that the appropriate hooks were called with correct names. |
Letting this sit for long term discussion. For 1.x a simple way to influence default limits would be great. |
Could it be possible to have |
Just writing down an idea: Would it be possible to name the queries automatically based on the location of the file calling |
Names based on file would be chaotic and keep us from refactoring. Also several cases have multiple queries in same file. |
I think this discussion is highly related: The query API requires a router behind the scenes, which is a nice way to get pluggability without feeling hacky. |
I might be able to get behind naming the queries based on what they would be if they were written in a falcore-style router. |
Then we can check this in and any transition later would be relatively smooth... |
Willing to call this dead. I think this is too low-level and entangles user code too much with internal logic. I have a better idea. |
DO NOT MERGE
TODO:
After this was put in place we could add names to the prominent public-facing lists/river queries. I'd suggest names prefixed with "elgg:" or "core:". E.g. "elgg:activity/all", "elgg:activity/owner", "elgg:blog/all", etc.
With this in place, one could alter $options arrays simply:
Or you could make reusable queries by putting a full set of options in the hook: