SystemConfigService.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace service;
  12. use app\admin\model\system\SystemConfig;
  13. class SystemConfigService
  14. {
  15. protected static $configList = null;
  16. public static function config($key)
  17. {
  18. if (self::$configList === null) self::$configList = self::getAll();
  19. return isset(self::$configList[$key]) ? self::$configList[$key] : null;
  20. }
  21. public static function get($key)
  22. {
  23. return SystemConfig::getValue($key);
  24. }
  25. public static function more($keys)
  26. {
  27. return SystemConfig::getMore($keys);
  28. }
  29. public static function getAll()
  30. {
  31. return SystemConfig::getAllConfig() ?: [];
  32. }
  33. public static function setUrl($keys)
  34. {
  35. $site_url = self::get('site_url');
  36. if (is_array($keys)) {
  37. foreach ($keys as &$item) {
  38. if (is_array($item) && isset($item['pic'])) {
  39. $item['pic'] = strstr($item['pic'], 'http') === false ? $site_url . $item['pic'] : $item['pic'];
  40. } else {
  41. $item = strstr($item, 'http') === false ? $site_url . $item : $item;
  42. }
  43. }
  44. } else {
  45. $keys = strstr($keys, 'http') === false ? $site_url . $keys : $keys;
  46. }
  47. return $keys;
  48. }
  49. public static function setOneValue($menu, $value)
  50. {
  51. return SystemConfig::setValue($menu, $value);
  52. }
  53. }