SystemConfigService.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/23
  6. */
  7. namespace service;
  8. use app\admin\model\system\SystemConfig;
  9. /** 获取系统配置服务类
  10. * Class SystemConfigService
  11. * @package service
  12. */
  13. class SystemConfigService
  14. {
  15. protected static $configList = null;
  16. /**获取系统配置
  17. * @param $key
  18. * @return mixed|null
  19. */
  20. public static function config($key)
  21. {
  22. if(self::$configList === null) self::$configList = self::getAll();
  23. return isset(self::$configList[$key]) ? self::$configList[$key] : null;
  24. }
  25. /**获取单个配置效率更高
  26. * @param $key
  27. * @return bool|mixed
  28. */
  29. public static function get($key)
  30. {
  31. return SystemConfig::getValue($key);
  32. }
  33. /** 获取多个配置
  34. * @param $keys ',' 隔开
  35. * @return array
  36. */
  37. public static function more($keys)
  38. {
  39. return SystemConfig::getMore($keys);
  40. }
  41. /**获取全部配置
  42. * @return array
  43. */
  44. public static function getAll()
  45. {
  46. return SystemConfig::getAllConfig()?:[];
  47. }
  48. }