SystemConfigService.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 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. $site_url=self::get('site_url');
  35. if(is_array($keys)){
  36. foreach ($keys as &$item){
  37. if(is_array($item) && isset($item['pic'])){
  38. $item['pic']=strstr($item['pic'],'http')===false ? $site_url.$item['pic'] : $item['pic'];
  39. }else{
  40. $item=strstr($item,'http')===false ? $site_url.$item : $item;
  41. }
  42. }
  43. }else{
  44. $keys=strstr($keys,'http')===false ? $site_url.$keys : $keys;
  45. }
  46. return $keys;
  47. }
  48. public static function setOneValue($menu,$value)
  49. {
  50. return SystemConfig::setValue($menu,$value);
  51. }
  52. }