Skip to content

Commit

Permalink
translation aggregation filter type support on entity source
Browse files Browse the repository at this point in the history
  • Loading branch information
behram committed Nov 12, 2016
1 parent c320b1f commit 219bd7b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Grid/Source/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr

$isDisjunction = $column->getDataJunction() === Column::DATA_DISJUNCTION;

$hasHavingClause = $column->hasDQLFunction() || $column->getIsAggregate();
$dqlMatches = [];
$hasHavingClause = $column->hasDQLFunction($dqlMatches) || $column->getIsAggregate();
if(isset($dqlMatches['function']) && $dqlMatches['function'] == 'translation_agg'){
$hasHavingClause = false;
}

$sub = $isDisjunction ? $this->query->expr()->orx() : ($hasHavingClause ? $this->query->expr()->andx() : $where);

Expand All @@ -378,11 +382,15 @@ public function execute($columns, $page = 0, $limit = 0, $maxResults = null, $gr

$fieldName = $this->getFieldName($columnForFilter, false);
$bindIndexPlaceholder = "?$bindIndex";
if (in_array($filter->getOperator(), array(Column::OPERATOR_LIKE,Column::OPERATOR_RLIKE,Column::OPERATOR_LLIKE,Column::OPERATOR_NLIKE,))) {
$fieldName = "LOWER($fieldName)";
if( in_array($filter->getOperator(), array(Column::OPERATOR_LIKE,Column::OPERATOR_RLIKE,Column::OPERATOR_LLIKE,Column::OPERATOR_NLIKE,))){
if(isset($dqlMatches['function']) && $dqlMatches['function'] == 'translation_agg'){
$fieldName = "LOWER(_translations.".$dqlMatches['field'].")";
}else{
$fieldName = "LOWER($fieldName)";
}
$bindIndexPlaceholder = "LOWER($bindIndexPlaceholder)";
}

$q = $this->query->expr()->$operator($fieldName, $bindIndexPlaceholder);

if ($filter->getOperator() == Column::OPERATOR_NLIKE || $filter->getOperator() == Column::OPERATOR_NSLIKE) {
Expand Down

0 comments on commit 219bd7b

Please sign in to comment.