6 declare(strict_types=1);
20 private $moduleDataSetup;
44 \
Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
45 \
Magento\Config\Model\Config\Structure\Proxy $structure,
46 \
Magento\Framework\Encryption\EncryptorInterface $encryptor,
49 $this->moduleDataSetup = $moduleDataSetup;
50 $this->structure = $structure;
52 $this->state = $state;
60 $this->moduleDataSetup->startSetup();
62 $this->reEncryptSystemConfigurationValues();
64 $this->moduleDataSetup->endSetup();
83 private function reEncryptSystemConfigurationValues()
85 $structure = $this->structure;
86 $paths = $this->state->emulateAreaCode(
88 function () use ($structure) {
89 return $structure->getFieldPathsByAttribute(
91 \
Magento\Config\Model\Config\Backend\Encrypted::class
97 $table = $this->moduleDataSetup->getTable(
'core_config_data');
98 $values = $this->moduleDataSetup->getConnection()->fetchPairs(
99 $this->moduleDataSetup->getConnection()
101 ->from(
$table, [
'config_id',
'value'])
102 ->where(
'path IN (?)',
$paths)
103 ->where(
'value NOT LIKE ?',
'')
106 $this->moduleDataSetup->getConnection()->update(
108 [
'value' => $this->encryptor->encrypt($this->encryptor->decrypt(
$value))],
109 [
'config_id = ?' => (
int)$configId]
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, \Magento\Config\Model\Config\Structure\Proxy $structure, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\App\State $state)