示例#1
0
 public function testSet()
 {
     $fileKey = 'testFileKey';
     $expectedValue = ['test' => ['path' => ['value1' => 'val1', 'value2' => 'val4', 'value3' => 'val3']]];
     $configData = new ConfigData($fileKey);
     $configData->set('test/path/value1', 'val1');
     $configData->set('test/path/value2', 'val2');
     $configData->set('test/path/value3', 'val3');
     $configData->set('test/path/value2', 'val4');
     $this->assertEquals($expectedValue, $configData->getData());
     $this->assertEquals($fileKey, $configData->getFileKey());
 }
示例#2
0
 /**
  * Change encryption key
  *
  * @param string|null $key
  * @return null|string
  * @throws \Exception
  */
 public function changeEncryptionKey($key = null)
 {
     // prepare new key, encryptor and new configuration segment
     if (!$this->writer->checkIfWritable()) {
         throw new \Exception(__('Deployment configuration file is not writable.'));
     }
     if (null === $key) {
         $key = md5($this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE));
     }
     $this->encryptor->setNewKey($key);
     $encryptSegment = new ConfigData(ConfigFilePool::APP_ENV);
     $encryptSegment->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $this->encryptor->exportKeys());
     $configData = [$encryptSegment->getFileKey() => $encryptSegment->getData()];
     // update database and config.php
     $this->beginTransaction();
     try {
         $this->_reEncryptSystemConfigurationValues();
         $this->_reEncryptCreditCardNumbers();
         $this->writer->saveConfig($configData);
         $this->commit();
         return $key;
     } catch (\Exception $e) {
         $this->rollBack();
         throw $e;
     }
 }
示例#3
0
 /**
  * Writes installation date to the configuration
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback.
  */
 private function writeInstallationDate()
 {
     $dateData = new ConfigData(ConfigFilePool::APP_ENV);
     $dateData->set(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE, date('r'));
     $configData = [$dateData->getFileKey() => $dateData->getData()];
     $this->deploymentConfigWriter->saveConfig($configData);
 }