您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

58 行
1.6KB

  1. <?php
  2. namespace backend\forms;
  3. use common\logic\Setting\SettingModule;
  4. use yii\base\Model;
  5. class AdminSettingsForm extends Model
  6. {
  7. public function __get($name)
  8. {
  9. return SettingModule::getInstance()->getAdminSettingBag()->get($name);
  10. }
  11. public function __set($name, $value)
  12. {
  13. $this->$name = $value;
  14. }
  15. public function rules()
  16. {
  17. $rulesArray = [];
  18. $typesArray = [
  19. 'string' => ['string', 'text'],
  20. 'date' => ['date'],
  21. 'boolean' => ['boolean'],
  22. 'integer' => ['integer'],
  23. 'double' => ['double', 'float'],
  24. ];
  25. foreach($typesArray as $rule => $typesSettingArray) {
  26. $rulesArray[] = [$this->getSettingNamesByTypeArray($typesSettingArray), $rule];
  27. }
  28. return $rulesArray;
  29. }
  30. public function attributeLabels()
  31. {
  32. $attributeLabelsArray = [];
  33. foreach(SettingModule::getInstance()->getAdminSettingDefinition()->getSettingDetailsFlat() as $settingDetail) {
  34. $attributeLabelsArray[$settingDetail->getName()] = $settingDetail->getLabel();
  35. }
  36. return $attributeLabelsArray;
  37. }
  38. public function getSettingNamesByTypeArray(array $typesSettingArray): array
  39. {
  40. $settingNamesTypeArray = [];
  41. foreach(SettingModule::getInstance()->getAdminSettingDefinition()->getSettingDetailsFlat() as $settingDetail) {
  42. if(in_array($settingDetail->getType(), $typesSettingArray)) {
  43. $settingNamesTypeArray[] = $settingDetail->getName();
  44. }
  45. }
  46. return $settingNamesTypeArray;
  47. }
  48. }
  49. ?>