Skip to content

Commit

Permalink
LeanMapperExtension: register() - fixed for nette/bootstrap 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Jul 12, 2023
1 parent 000efc4 commit 2af4a72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/LeanMapperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,16 @@ protected function registerInMapper(ServiceDefinition $mapper, array $mapping =
* @param string $name
* @return void
*/
public static function register(\Nette\Bootstrap\Configurator $configurator, $name = 'leanmapper')
public static function register(\Nette\Configurator $configurator, $name = 'leanmapper')
{
if (!is_array($configurator->onCompile)) {
if ($configurator->onCompile === NULL) { // @phpstan-ignore-line
$configurator->onCompile = [];

} elseif (!is_array($configurator->onCompile)) {
throw new \RuntimeException("Configurator::onCompile must be array, iterable " . gettype($configurator->onCompile) . ' given.');
}

$configurator->onCompile[] = function (\Nette\Bootstrap\Configurator $configurator, Nette\DI\Compiler $compiler) use ($name) {
$configurator->onCompile[] = function (\Nette\Configurator $configurator, Nette\DI\Compiler $compiler) use ($name) {
$compiler->addExtension($name, new LeanMapperExtension());
};
}
Expand Down

0 comments on commit 2af4a72

Please sign in to comment.