-
Notifications
You must be signed in to change notification settings - Fork 35
EZP-26273: Use QueryType for the top menu #39
Conversation
ab9b2a3
to
92940b0
Compare
+1 |
1 similar comment
+1 |
- '@ezpublish.api.service.location' | ||
- '@ezpublish.config.resolver' | ||
- '@app.criteria.menu' | ||
- '@ezpublish.query_type.registry' |
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.
You could simplify dependencies here by passing the QueryType directly: - '@app.query_type.menu'
. Then you don't need to use the registry anymore.
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.
Yes, I know. It's only for demonstration purpose, look: https://github.com/ezsystems/ezplatform-demo/pull/39/files#diff-71435085ac34f5c4748063a144167686R43
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.
Hmm, I'm not sure it's really relevant to demonstrate the complicated way, and comment out with the simplest one. I'd instead inject the query type, and explain that the registry could be used instead.
Both work, of course.
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.
Changed. If it's too complicated we should be simplify it :)
11e99ad
to
7419c94
Compare
@bdunogier can I ask you for a final review? |
big boss, can you have a look? ;) @bdunogier |
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.
Couple minor remarks. Feel free to adopt them or not, it's good in both cases, as far as i'm concerned.
/** | ||
* @param string[] $value | ||
*/ | ||
public function setLanguages($value) |
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.
If the parameter is always an array, you should typehint it as such.
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.
Good point! I forgot about it.
new Query\Criterion\Visibility(Query\Criterion\Visibility::VISIBLE), | ||
new Query\Criterion\Location\Depth( | ||
Query\Criterion\Operator::BETWEEN, | ||
[ |
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.
No need to wrap this array's content on multiple lines, it will be as readable on one line. Importing eZ\Publish\API\Repository\Values\Content\Query\Criterion
in the current namespace would also allow you to shorten this down:
$criteria = new Criterion\LogicalAnd([
new Criterion\Visibility(Criterion\Visibility::VISIBLE),
new Criterion\Location\Depth(Criterion\Operator::BETWEEN, [1, 2]),
new Criterion\Subtree('/1/2/'),
new Criterion\LanguageCode($this->languages),
Also, could the depth be handled as new Criterion\Location\Depth(Criterion\Operator::LTE, 2)
?
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.
Works like a charm, thank you, didn't know that!
7419c94
to
76339c8
Compare
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.
+1. But do you know why Travis is failing ?
it just stops working one day ;) |
https://jira.ez.no/browse/EZP-26273