forked from fecshop/yii2_fecshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStore.php
71 lines (56 loc) · 1.57 KB
/
Store.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
<?php
/**
* FecShop file.
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\components;
use Yii;
use yii\base\BootstrapInterface;
use yii\base\Component;
/**
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Store extends Component implements BootstrapInterface
{
public $appName;
public $_base_config;
protected $_modelName = '\fecshop\models\mysqldb\StoreBaseConfig';
protected $_model;
//
public $serviceMongodbName = 'mongodb';
public $serviceMysqldbName = 'mysqldb';
//
public $enable = 1;
public $disable = 2;
// 初始化的bootstrap
public function bootstrap($app)
{
if ($this->appName == 'appadmin') {
Yii::$service->admin->bootstrap($app);
} else {
Yii::$service->store->bootstrap($app);
}
}
// 得到配置值
/**
* @param $key | string, 配置的主Key
* @param $subKey | string, 配置的子key
*/
public function get($key, $subKey = '')
{
$this->initBaseConfig();
if (!$subKey) {
return isset($this->_base_config[$key]) ? $this->_base_config[$key] : null;
}
return isset($this->_base_config[$key][$subKey]) ? $this->_base_config[$key][$subKey] : null;
}
public function initBaseConfig()
{
if (!$this->_base_config) {
$this->_base_config = Yii::$service->storeBaseConfig->getAllConfig();
}
}
}