Skip to content

Commit 26a30b4

Browse files
lookymandg
authored andcommitted
CompilerExtension: added validate method
1 parent c1298b5 commit 26a30b4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/DI/CompilerExtension.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,19 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
117117
{
118118
}
119119

120+
121+
/**
122+
* Checks whether $config contains only $expected items.
123+
* @return void
124+
* @throws \Nette\InvalidStateException
125+
*/
126+
protected function validate(array $config, array $expected, $name = NULL)
127+
{
128+
if ($extra = array_diff_key($config, $expected)) {
129+
$name = $name ?: $this->name;
130+
$extra = implode(", $name.", array_keys($extra));
131+
throw new Nette\InvalidStateException("Unknown option $name.$extra.");
132+
}
133+
}
134+
120135
}

0 commit comments

Comments
 (0)