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

SettingDefinition.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace common\logic\Setting;
  3. use common\logic\AbstractDefinition;
  4. use common\logic\Setting\SettingDetails\Admin\AdminSettingDefinition;
  5. use common\logic\Setting\SettingDetails\Producer\ProducerSettingDefinition;
  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. }