You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Printer.php 1.3KB

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