Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }