Skip to content

Commit 5422718

Browse files
sammisammi
authored andcommitted
Fixed: #254
1 parent 6015d84 commit 5422718

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

EMongoDataProvider.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@ class EMongoDataProvider extends CActiveDataProvider
1313
* @var string
1414
*/
1515
public $modelClass;
16-
16+
1717
/**
1818
* The AR finder instance (eg <code>Post::model()</code>).
1919
* This property can be set by passing the finder instance as the first parameter
2020
* to the constructor. For example, <code>Post::model()->published()</code>.
2121
* @var EMongoModel
2222
*/
2323
public $model;
24-
24+
2525
/**
2626
* The name of key attribute for {@link modelClass}. If not set,
2727
* it means the primary key of the corresponding database table will be used.
2828
* @var string
2929
*/
3030
public $keyAttribute = '_id';
31-
31+
3232
/**
3333
* @var array The criteria array
3434
*/
3535
private $_criteria;
36-
36+
3737
/**
3838
* The internal MongoDB cursor as a MongoCursor instance
3939
* @var EMongoCursor|MongoCursor
4040
*/
4141
private $_cursor;
42-
42+
4343
/**
4444
* @var EMongoSort
4545
*/
@@ -99,7 +99,7 @@ public function fetchData()
9999
// I have not refactored this line considering that the condition may have changed from total item count to here, maybe.
100100
$this->_cursor = $this->model->find(
101101
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()
103103
);
104104

105105
// If we have sort and limit and skip setup within the incoming criteria let's set it
@@ -159,6 +159,25 @@ public function calculateTotalItemCount()
159159
return $this->_cursor->count();
160160
}
161161

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+
162181
/**
163182
* Returns the sort object. We don't use the newer getSort function because it does not have the same functionality
164183
* between 1.1.10 and 1.1.13, the functionality we need is actually in 1.1.13 only

0 commit comments

Comments
 (0)