Express.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\express;
  12. use crmeb\basic\BaseManager;
  13. use crmeb\services\AccessTokenServeService;
  14. use think\Container;
  15. use think\facade\Config;
  16. /**
  17. * Class Express
  18. * @package crmeb\services\express
  19. * @mixin \crmeb\services\express\storage\Express
  20. */
  21. class Express extends BaseManager
  22. {
  23. /**
  24. * 空间名
  25. * @var string
  26. */
  27. protected $namespace = '\\crmeb\\services\\express\\storage\\';
  28. /**
  29. * 默认驱动
  30. * @return mixed
  31. */
  32. protected function getDefaultDriver()
  33. {
  34. return Config::get('express.default', 'express');
  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'] ?? '', app()->cache);
  51. $handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
  52. $this->config = [];
  53. return $handle;
  54. }
  55. }