1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

#1188 - Simplified and optimized parameter un-setting logic

This commit is contained in:
Marco Pivetta 2014-11-27 18:08:11 +01:00
parent ac0f1b2ce2
commit f536daa1e4

View file

@ -261,13 +261,19 @@ class Paginator implements \Countable, \IteratorAggregate
$parser = new Parser($countQuery); $parser = new Parser($countQuery);
$parameterMappings = $parser->parse()->getParameterMappings(); $parameterMappings = $parser->parse()->getParameterMappings();
$parameters = $countQuery->getParameters(); /* @var $parameters \Doctrine\Common\Collections\Collection|\Doctrine\ORM\Query\Parameter[] */
foreach ($parameters as $k => $param){ $parameters = $countQuery->getParameters();
if( ! array_key_exists($param->getName(), $parameterMappings)) {
$parameters->remove($k); foreach ($parameters as $key => $parameter) {
$parameterName = $parameter->getName();
if( ! (isset($parameterMappings[$parameterName]) || array_key_exists($parameterName, $parameterMappings))) {
unset($parameters[$key]);
} }
} }
$countQuery->setParameters($parameters); $countQuery->setParameters($parameters);
return $countQuery; return $countQuery;
} }
} }