create a dedicated method for count loop function

This commit is contained in:
Manuel Raynaud
2014-01-23 17:13:48 +01:00
parent 2cee70a2b7
commit c0f5002db9
2 changed files with 23 additions and 1 deletions

View File

@@ -333,6 +333,28 @@ abstract class BaseLoop
}
}
public function count()
{
$count = 0;
if ($this instanceof PropelSearchLoopInterface) {
$searchModelCriteria = $this->buildModelCriteria();
if (null === $searchModelCriteria) {
$count = 0;
} else {
$count = $searchModelCriteria->count();
}
} elseif ($this instanceof ArraySearchLoopInterface) {
$searchArray = $this->buildArray();
if (null === $searchArray) {
$count = 0;
} else {
$count = count($searchArray);
}
}
return $count;
}
/**
* @param $pagination
* @return LoopResult

View File

@@ -91,7 +91,7 @@ class TheliaLoop extends AbstractSmartyPlugin
$dummy = null;
return $loop->exec($dummy, true);
return $loop->count();
}
/**