Skip to content

Conversation

@bdunogier
Copy link
Contributor

@bdunogier bdunogier commented Jun 12, 2016

Implements EZP-24624
Reopening of #1473 & #1460
BDD scenario

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. See the BDD specs linked above for code examples.

The view is configured to use ez_query:contentQueryAction. 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.

A working configuration example, with a QueryType, can be found in the BDD scenario.

@crevillo
Copy link
Contributor

crevillo commented Jun 13, 2016

hi @bdunogier , a question about
blogPathString: @=location.pathString. Will it work if we quote the @=... part? i mean
blogPathString: "@=location.pathString". Asking because looks symfony 3 will make us quote of this kind of things starting with @

Edit: now i see in the md you're quoting it, so looks it will work

@bdunogier
Copy link
Contributor Author

It should have been quoted, I'll fix the example. So the answer is "yes" :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitipick: Location

@yannickroger
Copy link
Contributor

Looks good to me.

Don't forget to add some phpdoc before merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually say that the children of the given location id are being returned as results. Do you consider that irrelevant to the feature, since it's up to the custom QueryType?

Copy link
Contributor Author

@bdunogier bdunogier Jun 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a fair question. We could add a sentence that asserts that the results are those we expect. It is kind of what "the Query results" means here, but it needs to be made more explicit. "The results of the LocationChidren query" are assigned to the children twig variable ?

@glye
Copy link
Member

glye commented Jun 13, 2016

Seems good. I second Yannick on doc.

@wizhippo
Copy link
Contributor

How about pagination support to return pager instance?

@bdunogier
Copy link
Contributor Author

bdunogier commented Jun 13, 2016

Pushed an improved version of the configuration. Let's use the behat scenario to discuss: https://github.com/ezsystems/ezpublish-kernel/pull/1675/files#diff-6d2810af82a8d9056f00de53f69e3702 :-)

@bdunogier
Copy link
Contributor Author

First behat implementation added, may pass. Will need refactoring :)

@bdunogier bdunogier force-pushed the feature-query_type_content_view_controller-ezp24258 branch from 34121c8 to 4ab96fd Compare June 13, 2016 20:25
@bdunogier
Copy link
Contributor Author

BDD implemented and passing !

@bdunogier
Copy link
Contributor Author

bdunogier commented Jun 14, 2016

@wizhippo as much as I'd like to do it, I'm not sure it can fit before the scope freeze (tomorrow).

How would you see that working when it comes to assigning pagination data to the template (naming, mainly) ?

@bdunogier bdunogier force-pushed the feature-query_type_content_view_controller-ezp24258 branch from 4ab96fd to c1bd329 Compare June 14, 2016 07:54
@@ -0,0 +1,58 @@
<?php
/**
* @license For full copyright and license information view LICENSE file distributed with this source code.
Copy link
Contributor

@andrerom andrerom Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we haven't fully (re)defined this, but I would have thought heading should be:

<?php

/**
 * File containing the BlaBla class.
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 */

Ideally skipping the file description (File containing the BlaBla class) in favor of rather spending the effort by having more useful class description, including usage examples.

Copy link
Contributor Author

@bdunogier bdunogier Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go for @license and @copyright alone, I don't really see the point of the first line anyway, and it seems that we don't really care about it.

@andrerom
Copy link
Contributor

andrerom commented Jun 14, 2016

How about pagination support to return pager instance?

@wizhippo as much as I'd like to do it, I'm not sure it can fit before the scope freeze (tomorrow).

How would you see that working when it comes to assigning pagination data to the template (naming, mainly) ?

Agreed this is a follow up topic.

Very Side comment on that, no need to discuss this here, more for when we tackle this perhaps: If we want to think a bit forward we should maybe rather think of using items as offsets, like github does, and as recommended for misc reasons, but will be difficult to handle sorting in a good way for the API so might not be applicable.

/**
* @param ContentView $view
*/
public function runQuery(ContentView $view, $method)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bdunogier bdunogier force-pushed the feature-query_type_content_view_controller-ezp24258 branch from 2d5a478 to 7e325f4 Compare June 14, 2016 16:34
@andrerom
Copy link
Contributor

andrerom commented Jun 14, 2016

+1 🐴 besides license nitpick.

You have quite a bit to demo tomorrow ;)

Bertrand Dunogier added 2 commits June 15, 2016 09:36
QueryTypeContentViewMapper is now an interface, in order to document both the input and output expectations.
The existing implementation is renamed to QueryParameterContentViewQueryTypeMapper.
@bdunogier bdunogier force-pushed the feature-query_type_content_view_controller-ezp24258 branch from 43f0caf to 2acb2e1 Compare June 15, 2016 07:36
@bdunogier
Copy link
Contributor Author

bdunogier commented Jun 15, 2016

Files headers taken care of.

@yannickroger
Copy link
Contributor

+1

@bdunogier bdunogier merged commit 3bb0e6b into master Jun 15, 2016
@bdunogier
Copy link
Contributor Author

And here we go.

@bdunogier bdunogier deleted the feature-query_type_content_view_controller-ezp24258 branch June 15, 2016 09:03
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.

6 participants