File tree Expand file tree Collapse file tree 3 files changed +19
-20
lines changed Expand file tree Collapse file tree 3 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Yii2 multiple input change log
4
4
2.18.0 (in development)
5
5
=======================
6
6
- #246 accept ` \Traversable ` in model attribute for ` yield ` compatibility (bscheshirwork)
7
+ - #250 accept ` \Traversable ` in TableRenderer and ListRenderer for ` yield ` compatibility (bscheshirwork)
7
8
8
9
2.17.0
9
10
======
Original file line number Diff line number Diff line change @@ -105,17 +105,16 @@ protected function renderBody()
105
105
$ rows = [];
106
106
107
107
if ($ this ->data ) {
108
- $ cnt = count ($ this ->data );
109
- if ($ this ->min === $ this ->max && $ cnt < $ this ->max ) {
110
- $ cnt = $ this ->max ;
108
+ $ j = 0 ;
109
+ foreach ($ this ->data as $ index => $ item ) {
110
+ if ($ j ++ <= $ this ->max ) {
111
+ $ rows [] = $ this ->renderRowContent ($ index , $ item );
112
+ } else {
113
+ break ;
114
+ }
111
115
}
112
-
113
- $ indices = array_keys ($ this ->data );
114
-
115
- for ($ i = 0 ; $ i < $ cnt ; $ i ++) {
116
- $ index = ArrayHelper::getValue ($ indices , $ i , $ i );
117
- $ item = ArrayHelper::getValue ($ this ->data , $ index , null );
118
- $ rows [] = $ this ->renderRowContent ($ index , $ item );
116
+ for ($ i = $ j ; $ i < $ this ->min ; $ i ++) {
117
+ $ rows [] = $ this ->renderRowContent ($ i );
119
118
}
120
119
} elseif ($ this ->min > 0 ) {
121
120
for ($ i = 0 ; $ i < $ this ->min ; $ i ++) {
Original file line number Diff line number Diff line change @@ -170,17 +170,16 @@ protected function renderBody()
170
170
$ rows = [];
171
171
172
172
if ($ this ->data ) {
173
- $ cnt = count ($ this ->data );
174
- if ($ this ->min === $ this ->max && $ cnt < $ this ->max ) {
175
- $ cnt = $ this ->max ;
173
+ $ j = 0 ;
174
+ foreach ($ this ->data as $ index => $ item ) {
175
+ if ($ j ++ <= $ this ->max ) {
176
+ $ rows [] = $ this ->renderRowContent ($ index , $ item );
177
+ } else {
178
+ break ;
179
+ }
176
180
}
177
-
178
- $ indices = array_keys ($ this ->data );
179
-
180
- for ($ i = 0 ; $ i < $ cnt ; $ i ++) {
181
- $ index = ArrayHelper::getValue ($ indices , $ i , $ i );
182
- $ item = ArrayHelper::getValue ($ this ->data , $ index , null );
183
- $ rows [] = $ this ->renderRowContent ($ index , $ item );
181
+ for ($ i = $ j ; $ i < $ this ->min ; $ i ++) {
182
+ $ rows [] = $ this ->renderRowContent ($ i );
184
183
}
185
184
} elseif ($ this ->min > 0 ) {
186
185
for ($ i = 0 ; $ i < $ this ->min ; $ i ++) {
You can’t perform that action at this time.
0 commit comments