create a dedicated method for count loop function
This commit is contained in:
@@ -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
|
* @param $pagination
|
||||||
* @return LoopResult
|
* @return LoopResult
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
|||||||
|
|
||||||
$dummy = null;
|
$dummy = null;
|
||||||
|
|
||||||
return $loop->exec($dummy, true);
|
return $loop->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user