AliasController.php
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Alias action handler
*/
class AliasController extends WRestController
{
protected $_modelName = "alias";
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',
'filterBy' => array(
'compare' => array(
'column' => array(
'alias' => 'query',
'recipient' => 'query',
'comment' => 'query'
),
'partial' => true,
'operator' => 'OR'
)
),
'limit' => 'limit',
'page' => 'page',
'order' => $this->getOrder(Yii::app()->request->getParam("sort"))
),
'delete' => 'WRestDeleteAction',
'get' => 'WRestGetAction',
'create' => array(
'class' => 'WRestCreateAction',
'scenario' => 'update'
),
'update' => array(
'class' => 'WRestUpdateAction',
'scenario' => 'update'
)
);
}
/**
* 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;
}
}