Printer.php 1.3 KB

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