Express.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace ln\services\express;
  3. use ln\basic\BaseManager;
  4. use ln\services\AccessTokenServeService;
  5. use think\Container;
  6. use think\facade\Config;
  7. /**
  8. * Class Express
  9. * @package ln\services\express
  10. * @mixin \ln\services\express\storage\Express
  11. */
  12. class Express extends BaseManager
  13. {
  14. /**
  15. * 空间名
  16. * @var string
  17. */
  18. protected $namespace = '\\ln\\services\\express\\storage\\';
  19. /**
  20. * 默认驱动
  21. * @return mixed
  22. */
  23. protected function getDefaultDriver()
  24. {
  25. return Config::get('express.default', 'express');
  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'] ?? '', app()->cache);
  42. $handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
  43. $this->config = [];
  44. return $handle;
  45. }
  46. }