Printer.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\printer;
  12. use crmeb\basic\BaseManager;
  13. use think\facade\Config;
  14. use think\Container;
  15. /**
  16. * Class Printer
  17. * @package crmeb\services\auth
  18. * @mixin \crmeb\services\printer\storage\YiLianYun
  19. */
  20. class Printer extends BaseManager
  21. {
  22. /**
  23. * 空间名
  24. * @var string
  25. */
  26. protected $namespace = '\\crmeb\\services\\printer\\storage\\';
  27. /**
  28. * @var object
  29. */
  30. protected $handleAccessToken;
  31. /**
  32. * 默认驱动
  33. * @return mixed
  34. */
  35. protected function getDefaultDriver()
  36. {
  37. return Config::get('printer.default', 'yi_lian_yun');
  38. }
  39. /**
  40. * 获取类的实例
  41. * @param $class
  42. * @return mixed|void
  43. */
  44. protected function invokeClass($class)
  45. {
  46. if (!class_exists($class)) {
  47. throw new \RuntimeException('class not exists: ' . $class);
  48. }
  49. $this->getConfigFile();
  50. if (!$this->config) {
  51. $this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
  52. }
  53. if (!$this->handleAccessToken) {
  54. $this->handleAccessToken = new AccessToken($this->config, $this->name, $this->configFile);
  55. }
  56. $handle = Container::getInstance()->invokeClass($class, [$this->name, $this->handleAccessToken, $this->configFile]);
  57. $this->config = [];
  58. return $handle;
  59. }
  60. }