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

склеить подготовленные данные через запятую, иначе брать значение из
_GET _POST
1 parent cf1e4c72
......@@ -9,6 +9,7 @@ class AliasController extends WRestController
public function actions() //determine which of the standard actions will support the controller
{
return array(
'list' => array( //use for get list of objects
'class' => 'WRestListAction',
......@@ -25,7 +26,7 @@ class AliasController extends WRestController
),
'limit' => 'limit',
'page' => 'page',
'order' => 'order'
'order' => $this->getOrder(Yii::app()->request->getParam("sort"))
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
......@@ -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!