Printer.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\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. * @mixin \crmeb\services\printer\storage\FeiEYun
  20. */
  21. class Printer extends BaseManager
  22. {
  23. /**
  24. * 空间名
  25. * @var string
  26. */
  27. protected $namespace = '\\crmeb\\services\\printer\\storage\\';
  28. /**
  29. * @var object
  30. */
  31. protected $handleAccessToken;
  32. /**
  33. * 默认驱动
  34. * @return mixed
  35. */
  36. protected function getDefaultDriver()
  37. {
  38. return Config::get('printer.default', 'yi_lian_yun');
  39. }
  40. /**
  41. * 获取类的实例
  42. * @param $class
  43. * @return mixed|void
  44. */
  45. protected function invokeClass($class)
  46. {
  47. if (!class_exists($class)) {
  48. throw new \RuntimeException('class not exists: ' . $class);
  49. }
  50. $this->getConfigFile();
  51. if (!$this->config) {
  52. $this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
  53. }
  54. if (!$this->handleAccessToken) {
  55. $this->handleAccessToken = new AccessToken($this->config, $this->name, $this->configFile);
  56. }
  57. $handle = Container::getInstance()->invokeClass($class, [$this->name, $this->handleAccessToken, $this->configFile]);
  58. $this->config = [];
  59. return $handle;
  60. }
  61. }