OXIDprojects / oxid_modules_config

OXID Module Configuration Im-/Exporter module by OXID Professional Services
GNU General Public License v3.0
3 stars 9 forks source link

remove default values from shop-config #28

Open alfredbez opened 5 years ago

alfredbez commented 5 years ago

It would be nice if the export can generate only kind of a diff from the default-values for each shop.

Here's example:

$default = [
  'GeneralShopSettings' => [
    'setting1' => true,
    'setting2' => false,
    'setting3' => false,
    'aModules' => [
      'OxidEsales\Eshop\Application\Model\Article' => [
        'Vendor\Modulename1\Model\Article',
        'Vendor\Modulename2\Model\Article',
        'Vendor\Modulename3\Model\Article',
      ],
    ],
  ],
];

$shop1 = [
  'GeneralShopSettings' => [
    'setting1' => true,
    'setting2' => true,
    'setting4' => true,
    'aModules' => [
      'OxidEsales\Eshop\Application\Model\Article' => [
        'Vendor\Modulename1\Model\Article',
        'Vendor\Modulename3\Model\Article',
      ],
    ],
  ],
];

$shop2 = [
  'GeneralShopSettings' => [
    'setting1' => true,
    'setting2' => true,
    'setting4' => true,
    'aModules' => [
      'OxidEsales\Eshop\Application\Model\Article' => [
        'Vendor\Modulename1\Model\Article',
        'Vendor\Modulename2\Model\Article',
        'Vendor\Modulename3\Model\Article',
      ],
    ],
  ],
];

expected result:

$cleanedShop1 = [
  'GeneralShopSettings' => [
    'setting2' => true,
    'setting4' => true,
    'aModules' => [
      'OxidEsales\Eshop\Application\Model\Article' => [
        'Vendor\Modulename1\Model\Article',
        'Vendor\Modulename3\Model\Article',
      ],
    ],
  ],
];

$cleanedShop2 = [
  'GeneralShopSettings' => [
    'setting2' => true,
    'setting4' => true,
  ],
]

We can hook into \OxidProfessionalServices\ModulesConfig\Core\ConfigExport::writeDataToFileSeperatedByShop and call a cleanup function before we call writeDataToFile.

What do you think?