Beispiel #1
0
 protected function getModuleConfigView(Structure $oStructure, Module $oModule)
 {
     $moduleConfigView = new ViewModuleConfiguration();
     $settings = [];
     if ($oModule->getPrimaryKey()) {
         $aModulesSettings = $oModule->getModuleSettings();
         foreach ($aModulesSettings as $oModuleSetting) {
             $type = Module::TYPE_LIST;
             if (!is_null($oModuleSetting->entity)) {
                 $oEntities = DataSource::factory($oModuleSetting->entity);
                 $oEntities->builder()->where('deleted=0');
                 $list = $oEntities->findAll();
                 $type = Module::TYPE_ENTITY;
             } elseif (!is_null($oModuleSetting->list)) {
                 $list = json_decode($oModuleSetting->list, true);
             } else {
                 $list = [];
             }
             $oStructureSetting = null;
             if ($oStructure->id) {
                 $oStructureSettings = DataSource::factory(StructureSetting::cls());
                 $oStructureSettings->builder()->where("structure_id={$oStructure->getPrimaryKey()}")->whereAnd()->where("module_setting_id={$oModuleSetting->getPrimaryKey()}");
                 /** @var StructureSetting[] $aStructureSettings */
                 $aStructureSettings = $oStructureSettings->findAll();
                 if (!empty($aStructureSettings)) {
                     $oStructureSetting = $aStructureSettings[0];
                 }
             }
             $settings[] = ['type' => $type, 'setting' => $oModuleSetting, 'list' => $list, 'value' => is_null($oStructureSetting) ? null : $oStructureSetting->value];
         }
     }
     $moduleConfigView->settings = $settings;
     return $moduleConfigView;
 }