1
0

SystemPresenter.php 796 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Presenters;
  3. use App\Models\System;
  4. /**
  5. * Class SystemPresenter
  6. *
  7. * @package namespace App\Presenters;
  8. */
  9. class SystemPresenter
  10. {
  11. protected $list;
  12. public function __construct()
  13. {
  14. $this->list = System::optionList();
  15. }
  16. /**
  17. * 根据key获取value
  18. *
  19. * @param $key
  20. * @return mixed
  21. */
  22. public function getKeyValue($key)
  23. {
  24. return isset($this->list[$key]) ? $this->list[$key] : '';
  25. }
  26. /**
  27. * 检查返回相应的value
  28. *
  29. * @param $key
  30. * @param $defaultValue
  31. * @return mixed
  32. */
  33. public function checkReturnValue($key, $defaultValue)
  34. {
  35. if ($defaultValue != "") {
  36. return $defaultValue;
  37. }
  38. return $this->getKeyValue($key);
  39. }
  40. }