Skip to content

Commit

Permalink
Merge 849ee84 into 11ab7ec
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Mar 1, 2019
2 parents 11ab7ec + 849ee84 commit 3307977
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

### Unreleased

* Add ConfigOverlay::exportAll()

### 1.2.0 2019-02-15

* Add ConfigAwareInterface / ConfigAwareTrait
Expand Down
16 changes: 16 additions & 0 deletions src/Util/ConfigOverlay.php
Expand Up @@ -201,6 +201,22 @@ public function export()
return $export;
}

/**
* exportAll returns the export of all contexts, separated into
* separate buckets keyed by context name.
*
* @return array
*/
public function exportAll()
{
$export = [];
foreach ($this->contexts as $name => $config) {
$exportToInsert = $config->export();
$export[$name] = $exportToInsert;
}
return $export;
}

/**
* @inheritdoc
*/
Expand Down
14 changes: 14 additions & 0 deletions tests/ConfigOverlayTest.php
Expand Up @@ -109,6 +109,20 @@ public function testExport()
$this->assertEquals('alias-a', $data['options']['a-a']);
}

public function testExportAll()
{
$overlay = $this->createOverlay();

// Set two different values in two contexts on the same key.
$overlay->getContext('cf')->set('duplicate', 'cf-value');
$overlay->getContext('a')->set('duplicate', 'a-value');

$export = $overlay->exportAll();

$this->assertEquals('cf-value', $export['cf']['duplicate']);
$this->assertEquals('a-value', $export['a']['duplicate']);
}

/**
* @expectedException Exception
*/
Expand Down

0 comments on commit 3307977

Please sign in to comment.