Skip to content

Commit

Permalink
use range in datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Cleuren committed Mar 16, 2015
1 parent 7aa0ae4 commit 599283a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DependencyInjection/RrdDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function __construct($container, $filename, $config, $create)
$this->container = $container;
$this->filename = $filename;
$this->config = $config;

$this->createDataSources();

if (!$create && !file_exists($this->filename)) {
throw new RrdDatabaseNotFoundException($this->filename);
Expand All @@ -26,6 +28,18 @@ public function __construct($container, $filename, $config, $create)
$this->create();
}
}

private function createDataSources()
{
foreach ($this->config['datasources'] as $key => $value) {
if(preg_match("/([\d]+)\.\.([\d]+)/", $key, $matches)) {
for($i = $matches[1]; $i <= $matches[2]; $i++) {
$this->config['datasources'][$i] = $value;
}
unset($this->config['datasources'][$key]);
}
}
}

private function create()
{
Expand Down

0 comments on commit 599283a

Please sign in to comment.