2 namespace TYPO3\CMS\Fluid\ViewHelpers;
74 public function render($each, $as, $key =
'', $reverse =
false, $iteration = null)
76 return static::renderStatic(
79 $this->renderingContext
93 if ($arguments[
'each'] === null) {
96 if (is_object($arguments[
'each']) && !$arguments[
'each'] instanceof \Traversable) {
97 throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception(
'ForViewHelper only supports arrays and objects implementing \Traversable interface', 1248728393);
100 if ($arguments[
'reverse'] ===
true) {
102 if (is_object($arguments[
'each'])) {
103 $arguments[
'each'] = iterator_to_array($arguments[
'each']);
105 $arguments[
'each'] = array_reverse($arguments[
'each']);
107 if ($arguments[
'iteration'] !== null) {
108 $iterationData = array(
111 'total' => count($arguments[
'each'])
116 foreach ($arguments[
'each'] as $keyValue => $singleElement) {
118 if ($arguments[
'key'] !==
'') {
121 if ($arguments[
'iteration'] !== null) {
122 $iterationData[
'isFirst'] = $iterationData[
'cycle'] === 1;
123 $iterationData[
'isLast'] = $iterationData[
'cycle'] === $iterationData[
'total'];
124 $iterationData[
'isEven'] = $iterationData[
'cycle'] % 2 === 0;
125 $iterationData[
'isOdd'] = !$iterationData[
'isEven'];
127 $iterationData[
'index']++;
128 $iterationData[
'cycle']++;
132 if ($arguments[
'key'] !==
'') {
135 if ($arguments[
'iteration'] !== null) {