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

47 lines
1.4KB

  1. <?php
  2. namespace domain\Setting;
  3. use domain\Setting\SettingDetails\Admin\AdminSettingDefinition;
  4. use domain\Setting\SettingDetails\Producer\ProducerSettingDefinition;
  5. use domain\_\AbstractDefinition;
  6. class SettingDefinition extends AbstractDefinition
  7. {
  8. public function getEntityFqcn(): string
  9. {
  10. return Setting::class;
  11. }
  12. public function getSettingDetailByName(string $name)
  13. {
  14. $adminSettingDefinition = AdminSettingDefinition::getInstance();
  15. $producerSettingDefinition = ProducerSettingDefinition::getInstance();
  16. $settingDetail = $this->findSettingDetailInArray($name, $adminSettingDefinition->getSettingDetails());
  17. if(!$settingDetail) {
  18. $this->findSettingDetailInArray($name, $producerSettingDefinition->getSettingDetails());
  19. }
  20. if(!$settingDetail) {
  21. throw new \Exception('SettingDetail non trouvé');
  22. }
  23. return $settingDetail;
  24. }
  25. public function findSettingDetailInArray(string $name, array $settingDetailsArray)
  26. {
  27. foreach($settingDetailsArray as $section => $subsectionsArray) {
  28. foreach($subsectionsArray as $subsection => $settingDetailsArray) {
  29. foreach($settingDetailsArray as $settingDetail) {
  30. if($name == $settingDetail->getName()) {
  31. return $settingDetail;
  32. }
  33. }
  34. }
  35. }
  36. return null;
  37. }
  38. }