Экстеншн дополнен проверко параметра order, если массив - то нужно

склеить подготовленные данные через запятую, иначе брать значение из
_GET _POST
1 parent cf1e4c72
...@@ -9,6 +9,7 @@ class AliasController extends WRestController ...@@ -9,6 +9,7 @@ class AliasController extends WRestController
public function actions() //determine which of the standard actions will support the controller public function actions() //determine which of the standard actions will support the controller
{ {
return array( return array(
'list' => array( //use for get list of objects 'list' => array( //use for get list of objects
'class' => 'WRestListAction', 'class' => 'WRestListAction',
...@@ -25,7 +26,7 @@ class AliasController extends WRestController ...@@ -25,7 +26,7 @@ class AliasController extends WRestController
), ),
'limit' => 'limit', 'limit' => 'limit',
'page' => 'page', 'page' => 'page',
'order' => 'order' 'order' => $this->getOrder(Yii::app()->request->getParam("sort"))
), ),
'delete' => 'WRestDeleteAction', 'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction', 'get' => 'WRestGetAction',
...@@ -39,4 +40,23 @@ class AliasController extends WRestController ...@@ -39,4 +40,23 @@ class AliasController extends WRestController
) )
); );
} }
/**
* Build order value
*/
private function getOrder( $paramValue ) {
if(!empty($paramValue) && ($jdecode = json_decode($paramValue))) {
if(!is_array($jdecode)) {
$jdecode = array($jdecode);
}
array_walk($jdecode, create_function('&$item, $key', '
$item = sprintf("%s %s", $item->property, $item->direction);
'));
return $jdecode;
}
return $paramValue;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!