Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

SettingImporter.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace domain\Setting;
  3. use domain\Setting\SettingDetails\Admin\AdminSettingDefinition;
  4. use domain\_\AbstractManager;
  5. class SettingImporter extends AbstractManager
  6. {
  7. protected AdminSettingDefinition $adminSettingDefinition;
  8. protected SettingBuilder $settingBuilder;
  9. public function loadDependencies(): void
  10. {
  11. $this->adminSettingDefinition = $this->loadService(AdminSettingDefinition::class);
  12. $this->settingBuilder = $this->loadService(SettingBuilder::class);
  13. }
  14. public function importFromDefinitions()
  15. {
  16. $this->importFromAdminSettingDefinition();
  17. $this->importFromProducerSettingDefinition();
  18. }
  19. public function importFromAdminSettingDefinition(): void
  20. {
  21. \Yii::$app->logic->setProducerContext(null);
  22. foreach ($this->adminSettingDefinition->getSettingDetailsFlat() as $settingDetail) {
  23. $this->settingBuilder->createSetting($settingDetail->getName());
  24. }
  25. }
  26. public function importFromProducerSettingDefinition(): void
  27. {
  28. // /!\ bien définir le contexte producteur
  29. }
  30. }