#1188 - Simplified and optimized parameter un-setting logic
This commit is contained in:
parent
ac0f1b2ce2
commit
f536daa1e4
1 changed files with 10 additions and 4 deletions
|
@ -261,13 +261,19 @@ class Paginator implements \Countable, \IteratorAggregate
|
|||
|
||||
$parser = new Parser($countQuery);
|
||||
$parameterMappings = $parser->parse()->getParameterMappings();
|
||||
$parameters = $countQuery->getParameters();
|
||||
foreach ($parameters as $k => $param){
|
||||
if( ! array_key_exists($param->getName(), $parameterMappings)) {
|
||||
$parameters->remove($k);
|
||||
/* @var $parameters \Doctrine\Common\Collections\Collection|\Doctrine\ORM\Query\Parameter[] */
|
||||
$parameters = $countQuery->getParameters();
|
||||
|
||||
foreach ($parameters as $key => $parameter) {
|
||||
$parameterName = $parameter->getName();
|
||||
|
||||
if( ! (isset($parameterMappings[$parameterName]) || array_key_exists($parameterName, $parameterMappings))) {
|
||||
unset($parameters[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$countQuery->setParameters($parameters);
|
||||
|
||||
return $countQuery;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue