Skip to content

Commit

Permalink
Merge pull request #196 from jonathanjfshaw/patch-3
Browse files Browse the repository at this point in the history
Add a storeOriginalConfiguration method
  • Loading branch information
jhedstrom authored Sep 21, 2018
2 parents e8ce2bb + 52a4c8b commit 724789d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Drupal/Driver/Cores/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ public function startCollectingMail() {
$config = \Drupal::configFactory()->getEditable('system.mail');
$data = $config->getRawData();

// Save the original values for restoration after.
$this->originalConfiguration['system.mail'] = $data;
// Save the values for restoration after.
$this->storeOriginalConfiguration('system.mail', $data);

// @todo Use a collector that supports html after D#2223967 lands.
$data['interface'] = ['default' => 'test_mail_collector'];
Expand Down Expand Up @@ -583,7 +583,7 @@ protected function startCollectingMailSystemMail() {
$data = $config->getRawData();

// Track original data for restoration.
$this->originalConfiguration['mailsystem.settings'] = $data;
$this->storeOriginalConfiguration('mailsystem.settings', $data);

// Convert all of the 'senders' to the test collector.
$data = $this->findMailSystemSenders($data);
Expand Down Expand Up @@ -619,4 +619,20 @@ protected function stopCollectingMailSystemMail() {
}
}

/**
* Store the original value for a piece of configuration.
*
* If an original value has previously been stored, it is not updated.
*
* @param string $name
* The name of the configuration.
* @param mixed $value
* The original value of the configuration.
*/
protected function storeOriginalConfiguration($name, $value) {
if (!isset($this->originalConfiguration[$name])) {
$this->originalConfiguration[$name] = $value;
}
}

}

0 comments on commit 724789d

Please sign in to comment.