|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
-
- namespace common\logic\Setting;
-
- use common\logic\AbstractDefinition;
- use common\logic\Setting\SettingDetails\Admin\AdminSettingDefinition;
- use common\logic\Setting\SettingDetails\Producer\ProducerSettingDefinition;
-
- class SettingDefinition extends AbstractDefinition
- {
- public function getEntityFqcn(): string
- {
- return Setting::class;
- }
-
- public function getSettingDetailByName(string $name)
- {
- $adminSettingDefinition = AdminSettingDefinition::getInstance();
- $producerSettingDefinition = ProducerSettingDefinition::getInstance();
-
- $settingDetail = $this->findSettingDetailInArray($name, $adminSettingDefinition->getSettingDetails());
- if(!$settingDetail) {
- $this->findSettingDetailInArray($name, $producerSettingDefinition->getSettingDetails());
- }
-
- if(!$settingDetail) {
- throw new \Exception('SettingDetail non trouvé');
- }
-
- return $settingDetail;
- }
-
- public function findSettingDetailInArray(string $name, array $settingDetailsArray)
- {
- foreach($settingDetailsArray as $section => $subsectionsArray) {
- foreach($subsectionsArray as $subsection => $settingDetailsArray) {
- foreach($settingDetailsArray as $settingDetail) {
- if($name == $settingDetail->getName()) {
- return $settingDetail;
- }
- }
- }
- }
-
- return null;
- }
- }
|