Store.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * FecShop file.
  4. * @link http://www.fecshop.com/
  5. * @copyright Copyright (c) 2016 FecShop Software LLC
  6. * @license http://www.fecshop.com/license/
  7. */
  8. namespace fecshop\components;
  9. use Yii;
  10. use yii\base\BootstrapInterface;
  11. use yii\base\Component;
  12. /**
  13. * @author Terry Zhao <2358269014@qq.com>
  14. * @since 1.0
  15. */
  16. class Store extends Component implements BootstrapInterface
  17. {
  18. public $appName;
  19. public $_base_config;
  20. protected $_modelName = '\fecshop\models\mysqldb\StoreBaseConfig';
  21. protected $_model;
  22. //
  23. public $serviceMongodbName = 'mongodb';
  24. public $serviceMysqldbName = 'mysqldb';
  25. //
  26. public $enable = 1;
  27. public $disable = 2;
  28. // 初始化的bootstrap
  29. public function bootstrap($app)
  30. {
  31. if ($this->appName == 'appadmin') {
  32. Yii::$service->admin->bootstrap($app);
  33. } else {
  34. Yii::$service->store->bootstrap($app);
  35. }
  36. }
  37. // 得到配置值
  38. /**
  39. * @param $key | string, 配置的主Key
  40. * @param $subKey | string, 配置的子key
  41. */
  42. public function get($key, $subKey = '')
  43. {
  44. $this->initBaseConfig();
  45. if (!$subKey) {
  46. return isset($this->_base_config[$key]) ? $this->_base_config[$key] : null;
  47. }
  48. return isset($this->_base_config[$key][$subKey]) ? $this->_base_config[$key][$subKey] : null;
  49. }
  50. public function initBaseConfig()
  51. {
  52. if (!$this->_base_config) {
  53. $this->_base_config = Yii::$service->storeBaseConfig->getAllConfig();
  54. }
  55. }
  56. }