Skip to content

Instantly share code, notes, and snippets.

@magevision
Last active October 10, 2022 11:44
Show Gist options
  • Save magevision/e528b6a736d5bf5a28b88ddb5a3ed17e to your computer and use it in GitHub Desktop.
Save magevision/e528b6a736d5bf5a28b88ddb5a3ed17e to your computer and use it in GitHub Desktop.
StoreConfigurationUsingDataPatch
<?php
declare(strict_types=1);
namespace MageVision\Blog79\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Config\Model\ResourceModel\Config as ResourceConfig;
class SetStoreConfiguration implements DataPatchInterface
{
private ModuleDataSetupInterface $moduleDataSetup;
private ResourceConfig $resourceConfig;
/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param ResourceConfig $resourceConfig
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
ResourceConfig $resourceConfig
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->resourceConfig = $resourceConfig;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$this->moduleDataSetup->startSetup();
$this->resourceConfig->saveConfig('general/locale/timezone', 'Europe/Berlin');
$this->moduleDataSetup->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment