@@ -126,10 +126,11 @@ protected function itemsToValues(IItems $items)
126
126
* Retrieve the values with the given ids.
127
127
*
128
128
* @param string[] $valueIds The ids of the values to retrieve.
129
+ * @param array $attrOnly The attribute names to obtain.
129
130
*
130
131
* @return array
131
132
*/
132
- protected function getValuesById ($ valueIds )
133
+ protected function getValuesById ($ valueIds, $ attrOnly = [] )
133
134
{
134
135
$ recursionKey = $ this ->getMetaModel ()->getTableName ();
135
136
@@ -142,7 +143,7 @@ protected function getValuesById($valueIds)
142
143
143
144
$ metaModel = $ this ->getSelectMetaModel ();
144
145
$ filter = $ metaModel ->getEmptyFilter ()->addFilterRule (new StaticIdList ($ valueIds ));
145
- $ items = $ metaModel ->findByFilter ($ filter , 'id ' );
146
+ $ items = $ metaModel ->findByFilter ($ filter , 'id ' , 0 , 0 , ' ASC ' , $ attrOnly );
146
147
unset($ tables [$ recursionKey ]);
147
148
148
149
return $ this ->itemsToValues ($ items );
@@ -172,6 +173,11 @@ public function valueToWidget($varValue)
172
173
*/
173
174
public function widgetToValue ($ varValue , $ itemId )
174
175
{
176
+ static $ cache ;
177
+ if (isset ($ cache [$ this ->get ('id ' )][$ varValue ])) {
178
+ return $ cache [$ this ->get ('id ' )][$ varValue ];
179
+ }
180
+
175
181
$ model = $ this ->getSelectMetaModel ();
176
182
$ alias = $ this ->getIdColumn ();
177
183
$ attribute = $ model ->getAttribute ($ alias );
@@ -220,9 +226,12 @@ public function widgetToValue($varValue, $itemId)
220
226
}
221
227
}
222
228
223
- $ value = $ this ->getValuesById (array ($ valueId ));
229
+ $ value = $ this ->getValuesById (
230
+ [$ valueId ],
231
+ [$ this ->getAliasColumn (), $ this ->getValueColumn (), $ this ->getIdColumn (), $ this ->getSortingColumn ()]
232
+ );
224
233
225
- return $ value [$ valueId ];
234
+ return $ cache [ $ this -> get ( ' id ' )][ $ varValue ] = $ value [$ valueId ];
226
235
}
227
236
228
237
/**
0 commit comments