Skip to content

Commit

Permalink
DI extensions use CompilerExtension::validateConfig()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 5, 2014
1 parent d7f6e94 commit 421e81f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
11 changes: 1 addition & 10 deletions src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function loadConfiguration()
$config = $this->getConfig($this->defaults);
}

$this->validate($config, $this->defaults, $old ? 'nette.application' : $this->name);
$this->validateConfig($this->defaults, $config, $old ? 'nette.application' : $this->name);

$application = $container->addDefinition('application') // no namespace for back compatibility
->setClass('Nette\Application\Application')
Expand All @@ -63,13 +63,4 @@ public function loadConfiguration()
}
}


private function validate(array $config, array $expected, $name)
{
if ($extra = array_diff_key($config, $expected)) {
$extra = implode(", $name.", array_keys($extra));
throw new Nette\InvalidStateException("Unknown option $name.$extra.");
}
}

}
11 changes: 1 addition & 10 deletions src/Bridges/ApplicationDI/LatteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function loadConfiguration()
$config['xhtml'] = $config['nette']['xhtml'];
}

$this->validate($config, $this->defaults, $this->name);
$this->validateConfig($this->defaults, $config);
$container = $this->getContainerBuilder();

$latteFactory = $container->addDefinition('nette.latteFactory')
Expand Down Expand Up @@ -115,13 +115,4 @@ public function addMacro($macro)
->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self'));
}


private function validate(array $config, array $expected, $name)
{
if ($extra = array_diff_key($config, $expected)) {
$extra = implode(", $name.", array_keys($extra));
throw new Nette\InvalidStateException("Unknown option $name.$extra.");
}
}

}
11 changes: 1 addition & 10 deletions src/Bridges/ApplicationDI/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function loadConfiguration()
$config = $this->getConfig($this->defaults);
}

$this->validate($config, $this->defaults, $old ? 'nette.routing' : $this->name);
$this->validateConfig($this->defaults, $config, $old ? 'nette.routing' : $this->name);

$router = $container->addDefinition('router') // no namespace for back compatibility
->setClass('Nette\Application\IRouter')
Expand All @@ -61,13 +61,4 @@ public function loadConfiguration()
}
}


private function validate(array $config, array $expected, $name)
{
if ($extra = array_diff_key($config, $expected)) {
$extra = implode(", $name.", array_keys($extra));
throw new Nette\InvalidStateException("Unknown option $name.$extra.");
}
}

}

0 comments on commit 421e81f

Please sign in to comment.