From f28011a230713a14a9d174861f4be9fa9d12e0d0 Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Sun, 14 Jan 2018 15:36:53 +0100 Subject: [PATCH 1/3] Add auto search for annotation extension name --- src/Kdyby/Doctrine/DI/OrmExtension.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Kdyby/Doctrine/DI/OrmExtension.php b/src/Kdyby/Doctrine/DI/OrmExtension.php index 460d33a3..2afbb5a6 100644 --- a/src/Kdyby/Doctrine/DI/OrmExtension.php +++ b/src/Kdyby/Doctrine/DI/OrmExtension.php @@ -622,8 +622,15 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri } if ($impl === self::ANNOTATION_DRIVER) { + $annotationExtensionName = self::ANNOTATION_DRIVER; + foreach ($this->compiler->getExtensions(AnnotationsExtension::class) as $annotationExtension) { + $annotationExtensionName = $annotationExtension->name; + + break; + } + $driver->arguments = [ - '@' . self::ANNOTATION_DRIVER . '.reader', + "@{$annotationExtensionName}.reader", Nette\Utils\Arrays::flatten($driver->arguments) ]; } From 2628727fb4a04e25abc530417d7b33bb698d05b0 Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Sun, 14 Jan 2018 17:35:17 +0100 Subject: [PATCH 2/3] Edit test configuration to more independent --- .../Doctrine/config/proxiesSessionAutoloading.neon | 2 +- tests/KdybyTests/nette-reset.neon | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/KdybyTests/Doctrine/config/proxiesSessionAutoloading.neon b/tests/KdybyTests/Doctrine/config/proxiesSessionAutoloading.neon index 5d64b4e4..f7e75f57 100644 --- a/tests/KdybyTests/Doctrine/config/proxiesSessionAutoloading.neon +++ b/tests/KdybyTests/Doctrine/config/proxiesSessionAutoloading.neon @@ -1,4 +1,4 @@ -console: +kdyby.console: disabled: true kdyby.doctrine: diff --git a/tests/KdybyTests/nette-reset.neon b/tests/KdybyTests/nette-reset.neon index 7e30eeb6..ca043704 100644 --- a/tests/KdybyTests/nette-reset.neon +++ b/tests/KdybyTests/nette-reset.neon @@ -3,9 +3,9 @@ php: extensions: - events: Kdyby\Events\DI\EventsExtension - console: Kdyby\Console\DI\ConsoleExtension - annotations: Kdyby\Annotations\DI\AnnotationsExtension + kdyby.events: Kdyby\Events\DI\EventsExtension + kdyby.console: Kdyby\Console\DI\ConsoleExtension + kdyby.annotations: Kdyby\Annotations\DI\AnnotationsExtension kdyby.doctrine: Kdyby\Doctrine\DI\OrmExtension @@ -16,7 +16,7 @@ kdyby.doctrine: hydrationCache: array -console: +kdyby.console: url: http://www.kdyby.org/ From 017b50a85851b07c0f768b95164a5597bef54331 Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Mon, 15 Jan 2018 13:53:32 +0100 Subject: [PATCH 3/3] Use autowire for annotation reader --- src/Kdyby/Doctrine/DI/OrmExtension.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Kdyby/Doctrine/DI/OrmExtension.php b/src/Kdyby/Doctrine/DI/OrmExtension.php index 2afbb5a6..23ca9613 100644 --- a/src/Kdyby/Doctrine/DI/OrmExtension.php +++ b/src/Kdyby/Doctrine/DI/OrmExtension.php @@ -622,15 +622,8 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri } if ($impl === self::ANNOTATION_DRIVER) { - $annotationExtensionName = self::ANNOTATION_DRIVER; - foreach ($this->compiler->getExtensions(AnnotationsExtension::class) as $annotationExtension) { - $annotationExtensionName = $annotationExtension->name; - - break; - } - $driver->arguments = [ - "@{$annotationExtensionName}.reader", + '@' . Doctrine\Common\Annotations\Reader::class, Nette\Utils\Arrays::flatten($driver->arguments) ]; }