@@ -13,33 +13,33 @@ class EMongoDataProvider extends CActiveDataProvider
13
13
* @var string
14
14
*/
15
15
public $ modelClass ;
16
-
16
+
17
17
/**
18
18
* The AR finder instance (eg <code>Post::model()</code>).
19
19
* This property can be set by passing the finder instance as the first parameter
20
20
* to the constructor. For example, <code>Post::model()->published()</code>.
21
21
* @var EMongoModel
22
22
*/
23
23
public $ model ;
24
-
24
+
25
25
/**
26
26
* The name of key attribute for {@link modelClass}. If not set,
27
27
* it means the primary key of the corresponding database table will be used.
28
28
* @var string
29
29
*/
30
30
public $ keyAttribute = '_id ' ;
31
-
31
+
32
32
/**
33
33
* @var array The criteria array
34
34
*/
35
35
private $ _criteria ;
36
-
36
+
37
37
/**
38
38
* The internal MongoDB cursor as a MongoCursor instance
39
39
* @var EMongoCursor|MongoCursor
40
40
*/
41
41
private $ _cursor ;
42
-
42
+
43
43
/**
44
44
* @var EMongoSort
45
45
*/
@@ -99,7 +99,7 @@ public function fetchData()
99
99
// I have not refactored this line considering that the condition may have changed from total item count to here, maybe.
100
100
$ this ->_cursor = $ this ->model ->find (
101
101
isset ($ criteria ['condition ' ]) && is_array ($ criteria ['condition ' ]) ? $ criteria ['condition ' ] : array (),
102
- isset ($ criteria ['project ' ]) && !empty ($ criteria ['project ' ]) ? $ criteria ['project ' ] : array ()
102
+ isset ($ criteria ['project ' ]) && !empty ($ criteria ['project ' ]) ? $ criteria ['project ' ] : array ()
103
103
);
104
104
105
105
// If we have sort and limit and skip setup within the incoming criteria let's set it
@@ -159,6 +159,25 @@ public function calculateTotalItemCount()
159
159
return $ this ->_cursor ->count ();
160
160
}
161
161
162
+ public function setSort ($ value )
163
+ {
164
+ if (is_array ($ value ))
165
+ {
166
+ if (isset ($ value ['class ' ]))
167
+ {
168
+ $ sort =$ this ->getSort ($ value ['class ' ]);
169
+ unset($ value ['class ' ]);
170
+ }
171
+ else
172
+ $ sort =$ this ->getSort ();
173
+
174
+ foreach ($ value as $ k =>$ v )
175
+ $ sort ->$ k =$ v ;
176
+ }
177
+ else
178
+ $ this ->_sort =$ value ;
179
+ }
180
+
162
181
/**
163
182
* Returns the sort object. We don't use the newer getSort function because it does not have the same functionality
164
183
* between 1.1.10 and 1.1.13, the functionality we need is actually in 1.1.13 only
0 commit comments