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

Alternative QueryController approach #1473

Closed
wants to merge 7 commits into from

Conversation

bdunogier
Copy link
Member

Story: http://jira.ez.no/browse/EZP-24624
DemoBundle implementation : ezsystems/DemoBundle#189

This is an alternative approach to what was done in #1460.

The goal is still to facilitate viewing of a list of content / locations. #1460 was based on a new "view" (as in content view or block view), where a QueryType got executed, and the results assigned to a template. But upon implementation, it appeared to be tedious, on simple use cases like a list of children.

In this approach, a built-in QueryController is added. It can be used in any content_view config to add the results of a QueryType to the view:

system:
    default:
        content_view:
            full:
                blog:
                    match:
                        Identifier\ContentType: [blog]
                    controller: 'ez_query:contentAction'
                    template: 'eZDemoBundle:full:blog.html.twig'
                    params:
                        query: 'DemoBundle:BlogPosts'
                        queryParameters:
                            blogPathString: @=location.pathString
                        variable: blog_posts_list
                        enablePager: true

The view is configured to use ez_query:contentAction. The controller action runs the QueryType specified as query, and sets the results to the variable specified as variable.

The elements from queryParameters are passed to the QueryType's getQuery() method.
The expression language can be used in any queryParameter by prefixing the value with @=. The expression is given the view, the location and the content. This makes it easy to pass any property from those value objects to generate the query.

The enable_pager parameter (not implemented yet) will pass the search results as a PagerFanta pager object. If set to false, an array will be passed instead.

TODO

  • BDD
  • Pager support
  • Extract to another package/bundle
  • Convert to a listener based approach, with the query parameters interpreted from the content_view level

@joaoinacio
Copy link

Nitpick: Doesn't look like it has anything to do with https://jira.ez.no/browse/EZP-24264 : LDAP authentication ;)
Maybe https://jira.ez.no/browse/EZP-24624 Implement the Query Controller?

@bdunogier
Copy link
Member Author

Thank you @joaoinacio :)

@andrerom
Copy link
Contributor

I think this is right direction, even if there are some things that don't appear clear, like how queryParameters is translated to a query, and how the convention is. Also would like to see how this might look with a built in children query type to make sure this can be used as opposed to creating a specific one per type. Sane defaults would also be great to avoid having to specify everything, for instance variable being "list" by default

@bdunogier
Copy link
Member Author

Added an example in the last commit, @andrerom.

@andrerom
Copy link
Contributor

thanks, and great to see it handling sorting based on the location transparently, a developer itch with the Search API from several.

@bdunogier
Copy link
Member Author

a developer itch

"itch" is a good choice of words :-)

@bdunogier bdunogier force-pushed the ezp24624-query_controller_take2 branch from e5adfd9 to f346e1f Compare March 17, 2016 08:12
@andrerom
Copy link
Contributor

Side: On that topic I still think Location Search API should have taken Location as an argument somehow as well to either do list (children) or tree searches, if so it could take sorting into account even down there. This was a longer discussion on this back when it was added, but this got labeled as the "higher level api" for later, and here we are I guess.

Bertrand Dunogier added 7 commits June 10, 2016 13:07
Entries from params.queryParameter will be searched for values starting
with '@=' (standard expression language syntax in yaml).

The expressions will be processed by the QueryController, and have access
to:
- `view`: the ContentView
- `content`: the rendered Content
- `location`: the rendered Location, if any

This expression would pass the location id as the parentLocationId queryParameter:
```
params:
  queryParameters:
    parentLocationId: @=location.id
```
@bdunogier bdunogier force-pushed the ezp24624-query_controller_take2 branch from f346e1f to 6471620 Compare June 10, 2016 11:07
@bdunogier
Copy link
Member Author

Will reopen with a cleaned up version.

@bdunogier bdunogier closed this Jun 12, 2016
@andrerom andrerom deleted the ezp24624-query_controller_take2 branch June 12, 2016 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants