Product.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services\product;
  12. use crmeb\basic\BaseManager;
  13. use crmeb\services\AccessTokenServeService;
  14. use think\facade\Config;
  15. use think\Container;
  16. /**
  17. * Class Product
  18. * @package crmeb\services\product
  19. * @mixin \crmeb\services\product\storage\Copy
  20. */
  21. class Product extends BaseManager
  22. {
  23. /**
  24. * 空间名
  25. * @var string
  26. */
  27. protected $namespace = '\\crmeb\\services\\product\\storage\\';
  28. /**
  29. * 默认驱动
  30. * @return mixed
  31. */
  32. protected function getDefaultDriver()
  33. {
  34. return Config::get('product.default', 'copy');
  35. }
  36. /**
  37. * 获取类的实例
  38. * @param $class
  39. * @return mixed|void
  40. */
  41. protected function invokeClass($class)
  42. {
  43. if (!class_exists($class)) {
  44. throw new \RuntimeException('class not exists: ' . $class);
  45. }
  46. $this->getConfigFile();
  47. if (!$this->config) {
  48. $this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
  49. }
  50. $handleAccessToken = new AccessTokenServeService($this->config['account'] ?? '', $this->config['secret'] ?? '');
  51. $handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
  52. $this->config = [];
  53. return $handle;
  54. }
  55. }