-
Notifications
You must be signed in to change notification settings - Fork 202
allow entity query conditions to be disabled #577
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 8.x-3.x #577 +/- ##
===========================================
- Coverage 80.79% 80.74% -0.06%
===========================================
Files 186 186
Lines 2854 2861 +7
===========================================
+ Hits 2306 2310 +4
- Misses 548 551 +3
Continue to review full report at Codecov.
|
@@ -297,6 +301,13 @@ protected function buildFilterConditions(QueryInterface $query, array $filter) { | |||
// Apply filter conditions. | |||
$conditions = !empty($filter['conditions']) ? $filter['conditions'] : []; | |||
foreach ($conditions as $condition) { | |||
// Set the condition to enabled by default. | |||
$enabled = (isset($condition['enabled'])) ? $condition['enabled'] : true; |
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.
We support "default" values in the annotation. I think it would be better to use that:
"enabled" = {
"default" = TRUE
"type" = "Boolean"
}
@@ -270,7 +270,11 @@ protected function applySort(QueryInterface $query, $sort) { | |||
*/ | |||
protected function applyFilter(QueryInterface $query, $filter) { | |||
if (!empty($filter) && is_array($filter)) { | |||
$query->condition($this->buildFilterConditions($query, $filter)); | |||
//Conditions can be disabled. Check we are not adding an empty condition group. | |||
$filter_conditions = $this->buildFilterConditions($query, $filter); |
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.
We use camelCase in our code ($filterConditions)
Thanks! |
#576