From 2af4a720c61a47b3a14b1f80f609b5c8de1d05e9 Mon Sep 17 00:00:00 2001 From: Jan Pecha Date: Wed, 12 Jul 2023 07:12:15 +0200 Subject: [PATCH] LeanMapperExtension: register() - fixed for nette/bootstrap 3.x --- src/LeanMapperExtension.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/LeanMapperExtension.php b/src/LeanMapperExtension.php index 704699d..1a4e968 100644 --- a/src/LeanMapperExtension.php +++ b/src/LeanMapperExtension.php @@ -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()); }; }