-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CmsPageFormTrait.php
48 lines (43 loc) · 1.54 KB
/
CmsPageFormTrait.php
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
<?php
namespace webkadabra\yii\modules\cms;
use yii;
/**
* Class CmsPageFormTrait
* @author sergii gamaiunov <[email protected]>
* @package webkadabra\yii\modules\cms
*/
trait CmsPageFormTrait
{
/**
* @return array
*/
public function getControllerRouteOptions()
{
$routesMap = AdminModule::getInstance()->availableControllerRoutes;
$dropdownOptions = $boundActionOptions = array();
// Loop controllers
foreach ($routesMap as $controllerId => $config) {
// Loop controller actions:
foreach ($config['actions'] as $actionId => $action_config) {
$actionPathKey = $controllerId . '/' . $actionId;
// Can haz action parameters? ^^
if (is_array($action_config) and isset($action_config['params'])) {
if (is_array($action_config['params'])) {
$boundActionOptions[$actionPathKey] = $action_config['params'];
} else {
$boundActionOptions[$actionPathKey] = array($action_config['params']);
}
}
$dropdownOptions[] = array(
'group' => $config['label'],
'value' => $actionPathKey,
'label' => (!is_array($action_config) ? $action_config : $action_config['label']),
);
}
}
return array(
'controllerActions' => $dropdownOptions,
'actionParameters' => $boundActionOptions,
);
}
}