-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathAdminModule.php
executable file
·74 lines (65 loc) · 1.97 KB
/
AdminModule.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fec;
use Yii;
use fec\helpers\CConfig;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class AdminModule extends \yii\base\Module
{
public $controllerNamespace ;
public $_currentDir ;
public $_currentNameSpace ;
public function init()
{
parent::init();
isset($this->_currentDir) && $this->configModuleParams();
# 默认layout文件
$this->layout = $this->layout ? $this->layout : "main.php";
}
public function configModuleParams(){
# 配置config文件
$config_file_dir = $this->_currentDir . '/etc/config.php';
if($this->_currentDir && file_exists($config_file_dir)){
$params_data = (require($config_file_dir));
}
# 设置参数
$params_data['_currentDir'] = $this->_currentDir;
$params_data['_currentNameSpace'] = $this->_currentNameSpace;
$params = $this->params;
if(is_array($params) && !empty($params)){
$params_data = \yii\helpers\ArrayHelper::merge($params,$params_data);
}
Yii::configure($this, ['params'=> $params_data]);
}
/*
public function init()
{
parent::init();
$theme = CConfig::getCurrentTheme();
# 定义views文件所在路径
$dir = \basename($this->_currentDir);
basename(dirname($_SERVER['PHP_SELF']));
$viewPath = __DIR__ . "/Theme/".$theme."/".strtolower($dir);
$this->setViewPath($viewPath);
# 定义模块专属的layout 文件 appadmin/code/Blog/Theme/default/article/layouts/main.php
//$this->layout = "main.php";
# 加载配置文件
$config_file_dir = $this->_currentDir . '/etc/config.php';
if(file_exists($config_file_dir)){
if(($params_data = (require($config_file_dir))) && !empty($params_data)){
Yii::configure($this, ['params'=> $params_data]);
}
}
$this->params['blockDir'] = str_replace("\\controllers","",$this->controllerNamespace);
}
*/
}