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

107 行
4.2KB

  1. <?php
  2. namespace domain\Setting\SettingDetails\Admin;
  3. use domain\Setting\SettingDefinition;
  4. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageIconSetting;
  5. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageSetting;
  6. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTitleSetting;
  7. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTypeSetting;
  8. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageDisplaySetting;
  9. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageIconSetting;
  10. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageSetting;
  11. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageTitleSetting;
  12. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageTypeSetting;
  13. use domain\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
  14. use domain\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
  15. use domain\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;
  16. use domain\Setting\SettingDetails\Admin\General\MaximumNumberProducersAdminSetting;
  17. use domain\Setting\SettingDetails\Admin\General\SupportOnlineAdminSetting;
  18. use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageDisplaySetting;
  19. class AdminSettingDefinition extends SettingDefinition
  20. {
  21. const SECTION_GENERAL = 'general';
  22. const SUBSECTION_GENERAL = 'general.main';
  23. const SECTION_ALERT_MESSAGE = 'alertmessage';
  24. const SUBSECTION_ALERT_MESSAGE_GLOBAL = 'alertmessage.global';
  25. const SUBSECTION_ALERT_MESSAGE_SUPPORT = 'alertmessage.support';
  26. public function getSettingDetails(): array
  27. {
  28. return [
  29. self::SECTION_GENERAL => [
  30. self::SUBSECTION_GENERAL => [
  31. new SupportOnlineAdminSetting(),
  32. new AdministratorEmailAdminSetting(),
  33. new AdministratorPhoneNumberAdminSetting(),
  34. new MaximumNumberProducersAdminSetting(),
  35. new ForumFlarumUrlAdminSetting(),
  36. ]
  37. ],
  38. self::SECTION_ALERT_MESSAGE => [
  39. self::SUBSECTION_ALERT_MESSAGE_GLOBAL => [
  40. new AdminAlertMessageDisplaySetting(),
  41. new AdminAlertMessageTypeSetting(),
  42. new AdminAlertMessageIconSetting(),
  43. new AdminAlertMessageTitleSetting(),
  44. new AdminAlertMessageSetting(),
  45. ],
  46. self::SUBSECTION_ALERT_MESSAGE_SUPPORT => [
  47. new AdminSupportAlertMessageDisplaySetting(),
  48. new AdminSupportAlertMessageTypeSetting(),
  49. new AdminSupportAlertMessageIconSetting(),
  50. new AdminSupportAlertMessageTitleSetting(),
  51. new AdminSupportAlertMessageSetting(),
  52. ],
  53. ]
  54. ];
  55. }
  56. public function getSectionLabels(): array
  57. {
  58. return [
  59. self::SECTION_GENERAL => 'General',
  60. self::SUBSECTION_GENERAL => 'General',
  61. self::SECTION_ALERT_MESSAGE => 'Message d\'alerte',
  62. self::SUBSECTION_ALERT_MESSAGE_GLOBAL => 'Global',
  63. self::SUBSECTION_ALERT_MESSAGE_SUPPORT => 'Support'
  64. ];
  65. }
  66. public function getSectionsArray(): array
  67. {
  68. $sectionsArray = [];
  69. foreach($this->getSettingDetails() as $sectionName => $subsectionsArray) {
  70. $sectionsArray[] = [
  71. 'name' => $sectionName,
  72. 'nameDisplay' => $this->getSectionLabelBySectionName($sectionName),
  73. ];
  74. }
  75. return $sectionsArray;
  76. }
  77. public function getSettingDetailsFlat(): array
  78. {
  79. $settingDetailsFlatArray = [];
  80. foreach($this->getSettingDetails() as $sectionsArray) {
  81. foreach($sectionsArray as $subsectionsArray) {
  82. foreach($subsectionsArray as $settingDetail) {
  83. $settingDetailsFlatArray[] = $settingDetail;
  84. }
  85. }
  86. }
  87. return $settingDetailsFlatArray;
  88. }
  89. public function getSectionLabelBySectionName(string $sectionName): string
  90. {
  91. return $this->getSectionLabels()[$sectionName];
  92. }
  93. }