Product.php 1.3 KB

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