-
Notifications
You must be signed in to change notification settings - Fork 16
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
WIP: First sketch of the OG context module. #252
Conversation
@@ -0,0 +1 @@ | |||
og_context: |
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.
There is a typo here: neogation
instead of negotation
. It's probably also not necessary to prefix the config ID with ogcontext
because the config system already automatically provides the prefix og_context.
.
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.
10x
@amitaibu Before I'll start implementing the changes don't you want me to moe og context plugin into OG core? |
I moved OG context into core. Now I can say I started the work on OG context. |
Another update - Now we have the next two cool, IMO, API: $plugins = Og::contextHandler()->getPlugins();
$plugin = Og::contextHandler()->getPlugin('entity'); |
* "uuid" = "uuid" | ||
* }, | ||
* links = { | ||
* "collection" = "/admin/structure/visibility_group" |
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.
Might not need to this PR....
OK. I got the rename of the classes. Now I need to extend the OgContext form |
What's the status here? |
I started to work on extending from |
@amitaibu I extended If some one can throw some tips that would be awesome. |
I dig a bit in the code and it seems that we need to create a service, in addition to the context group resolver, that will look like this:
and that service will use the logic I created so far. After that we can have in any plugins something like this:
But IMO this will be another PR. In the mean while I'll keep working in the tests. |
I added a skeleton for the test and this time I did not got any weird errors from PHPUNIT. |
Great. Can you please re-roll, and re-open this PR against Gizra/og |
One the tests will work as expected I'll create new PR against gizra/OG. In the meanwhile don't close the PR. 10x. |
@RoySegall would you be OK if I continue on this? I have time to work on it this week. I would like to start with adopting the naming scheme that @amitaibu suggested in #282 (comment):
And then secondly get the tests green. |
* | ||
* @package Drupal\og | ||
*/ | ||
interface GroupResolverHandlerInterface { |
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.
What is the purpose of this class? The documentation doesn't explain it. Why do we need an additional class to handle GroupResolver plugins? Isn't this the task of GroupResolverManager
?
This is confusing to me since this class is only used in tests so far, there is no real code calling into it. It would be really helpful if the purpose of this class was documented.
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.
OK so this is a service that is responsible for looping over the context plugins and resolving the group that best matches the current state. It's a bit strange that most of the methods here are directly related to retrieving and updating plugins, which sounds like the job of the plugin manager to me.
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 think this would be much clearer if this was renamed to GroupResolverInterface
, the 'handler' part is what makes it confusing to me, it brings up associations with EntityHandlerInterface
:)
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.
or maybe OgGroupResolverInterface
?
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 had a look through the code but it seems to me that the chosen approach is more complex than needed. Maybe I am not seeing the use cases that require this complex approach, but the way I imagined this to work was like this:
In my mind the whole procedure would be like 50 lines of code + a couple hundred lines for the default config, the individual plugins and tests. This approach with the separate handler and saving plugin configuration in a dedicated |
I always enjoy seeing your code review! I think your analysis is very good, with a single remark:
OgContextProvider::getRuntimeContexts() will call the Then, it will apply some simple (hardcoded) rule to get the "Best matching" group, by order:
|
Thanks for the feedback! With your permission I will continue this work and try to bring it to conclusion. I'll make a new PR with the simplified approach. |
👍 |
@pfrenssen Any new on this one? I kind of lost context on this one in the past few weeks. |
Goal
Port og-context module to OG8.
GroupResolver
are plugins that can extract group for the pages or entities they are acting on. One can get the groups from the router, and another arbitrary one that will do it by the time of the day.Those plugins pass their groups to the
OgContextProvider
that will select the "best matching" one, and return it. The best matching logic is currently (by order):Naming
Context provider : class OgContext implements ContextProviderInterface {
Plugin manager: class GroupResolverManager extends DefaultPluginManager {
Single Plugin: class GroupResolver extends GroupResolverInterface {
The GroupResolver plugins will return multiple groups, but eventually OgContextProvider will select only a single one. The logic is that when your theme/language/whatever needs to change according to context it should act only on a single context.