-
Notifications
You must be signed in to change notification settings - Fork 123
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
Added action plugin: Fetch entities by view #467
base: 8.x-3.x
Are you sure you want to change the base?
Conversation
|
||
// Pull values out of contexts. | ||
$contexts = array_map(function ($context) { | ||
return $context->getContextData()->getValue(); |
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.
This can be nice done by implementing doExecute() instead.
|
||
// Convert entities into entity ids. | ||
$contexts = array_map(function ($context) { | ||
return $context instanceof EntityInterface ? $context->id() : $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.
Interesting. Mabye we should add some support to allow ids to be required only.
} | ||
} | ||
|
||
foreach (Views::getApplicableViews('rules') as $data) { |
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.
ouch, is there no method on the storage we can use?
* rules = TRUE | ||
* ) | ||
*/ | ||
class Rules extends DisplayPluginBase { |
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.
Let's call this "Rules context provider" ? Theoretically this could be used by other modules also.
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.
That said, maybe does Ctools already have something in that direction we could use instead?
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.
Thanks for the PR - this looks great already. I started with a review!
I've added a plugin that enables rules to fetch lists of entities from view. Similar to the action available in Rules bonus pack, but with typed contexts.
There is a views display plugin to be used for views that act as rules data sources. A plugin deriver will provide a rules action for every views display using this plugin, and add views contexts based on the views argument definitions.
I'm aware that there is no test coverage and probably some bugs. I would like to discuss feasibility of this approach before going any further.