Product.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User: song
  5. * Date: 2020/9/28/0028
  6. * Time: 16:14
  7. */
  8. namespace crmeb\services\product;
  9. use crmeb\basic\BaseManager;
  10. use crmeb\services\AccessTokenServeService;
  11. use think\facade\Config;
  12. use think\Container;
  13. /**
  14. * Class Product
  15. * @package crmeb\services\product
  16. * @mixin \crmeb\services\product\storage\Copy
  17. */
  18. class Product extends BaseManager
  19. {
  20. /**
  21. * 空间名
  22. * @var string
  23. */
  24. protected $namespace = '\\crmeb\\services\\product\\storage\\';
  25. /**
  26. * 默认驱动
  27. * @return mixed
  28. */
  29. protected function getDefaultDriver()
  30. {
  31. return Config::get('product.default', 'copy');
  32. }
  33. /**
  34. * 获取类的实例
  35. * @param $class
  36. * @return mixed|void
  37. */
  38. protected function invokeClass($class)
  39. {
  40. if (!class_exists($class)) {
  41. throw new \RuntimeException('class not exists: ' . $class);
  42. }
  43. $this->getConfigFile();
  44. if (!$this->config) {
  45. $this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
  46. }
  47. $handleAccessToken = new AccessTokenServeService($this->config['account'] ?? '', $this->config['secret'] ?? '');
  48. $handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
  49. $this->config = [];
  50. return $handle;
  51. }
  52. }