Skip to content
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

Open
wants to merge 2 commits into
base: 8.x-3.x
Choose a base branch
from

Conversation

pmelab
Copy link

@pmelab pmelab commented Aug 10, 2016

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.


// Pull values out of contexts.
$contexts = array_map(function ($context) {
return $context->getContextData()->getValue();
Copy link
Owner

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;
Copy link
Owner

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) {
Copy link
Owner

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 {
Copy link
Owner

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.

Copy link
Owner

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?

Copy link
Owner

@fago fago left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants