-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathBaseModule.php
executable file
·49 lines (41 loc) · 1.24 KB
/
BaseModule.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
<?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 BaseModule extends \yii\base\Module
{
public $controllerNamespace ;
public $_currentDir ;
public $_currentNameSpace ;
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);
}
}