You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3KB

  1. <?php
  2. namespace common\logic\Setting\SettingDetails\Admin;
  3. use common\logic\Setting\SettingDefinition;
  4. use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
  5. use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
  6. use common\logic\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;
  7. use common\logic\Setting\SettingDetails\Admin\General\MaximumNumberProducersAdminSetting;
  8. use common\logic\Setting\SettingDetails\Admin\General\SupportDeveloperOnlineAdminSetting;
  9. class AdminSettingDefinition extends SettingDefinition
  10. {
  11. const SECTION_GENERAL = 'general';
  12. const SUBSECTION_GENERAL = 'general.main';
  13. public function getSettingDetails(): array
  14. {
  15. return [
  16. self::SECTION_GENERAL => [
  17. self::SUBSECTION_GENERAL => [
  18. new SupportDeveloperOnlineAdminSetting(),
  19. new AdministratorEmailAdminSetting(),
  20. new AdministratorPhoneNumberAdminSetting(),
  21. new MaximumNumberProducersAdminSetting(),
  22. new ForumFlarumUrlAdminSetting(),
  23. ]
  24. ],
  25. ];
  26. }
  27. public function getSectionLabels(): array
  28. {
  29. return [
  30. self::SECTION_GENERAL => 'General',
  31. self::SUBSECTION_GENERAL => 'General',
  32. ];
  33. }
  34. public function getSectionsArray(): array
  35. {
  36. $sectionsArray = [];
  37. foreach($this->getSettingDetails() as $sectionName => $subsectionsArray) {
  38. $sectionsArray[] = [
  39. 'name' => $sectionName,
  40. 'nameDisplay' => $this->getSectionLabelBySectionName($sectionName),
  41. ];
  42. }
  43. return $sectionsArray;
  44. }
  45. public function getSettingDetailsFlat(): array
  46. {
  47. $settingDetailsFlatArray = [];
  48. foreach($this->getSettingDetails() as $sectionsArray) {
  49. foreach($sectionsArray as $subsectionsArray) {
  50. foreach($subsectionsArray as $settingDetail) {
  51. $settingDetailsFlatArray[] = $settingDetail;
  52. }
  53. }
  54. }
  55. return $settingDetailsFlatArray;
  56. }
  57. public function getSectionLabelBySectionName(string $sectionName): string
  58. {
  59. return $this->getSectionLabels()[$sectionName];
  60. }
  61. }