Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

111 lines
4.5KB

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