diff --git a/src/Kdyby/Doctrine/DI/OrmExtension.php b/src/Kdyby/Doctrine/DI/OrmExtension.php index 460d33a3..fea4b7eb 100644 --- a/src/Kdyby/Doctrine/DI/OrmExtension.php +++ b/src/Kdyby/Doctrine/DI/OrmExtension.php @@ -294,8 +294,8 @@ protected function processEntityManager($name, array $defaults) if (empty($config['metadata'])) { $metadataDriver->addSetup('setDefaultDriver', [ new Statement($this->metadataDriverClasses[self::ANNOTATION_DRIVER], [ - [$builder->expand('%appDir%')], - 2 => $this->prefix('@cache.' . $name . '.metadata') + '@' . Doctrine\Common\Annotations\Reader::class, + [Nette\DI\Helpers::expand('%appDir%', $builder->parameters)] ]) ]); } @@ -623,7 +623,7 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri if ($impl === self::ANNOTATION_DRIVER) { $driver->arguments = [ - '@' . self::ANNOTATION_DRIVER . '.reader', + '@' . Doctrine\Common\Annotations\Reader::class, Nette\Utils\Arrays::flatten($driver->arguments) ]; } diff --git a/tests/KdybyTests/Doctrine/Extension.phpt b/tests/KdybyTests/Doctrine/Extension.phpt index 28b86d6e..7a119b5a 100644 --- a/tests/KdybyTests/Doctrine/Extension.phpt +++ b/tests/KdybyTests/Doctrine/Extension.phpt @@ -155,6 +155,21 @@ class ExtensionTest extends Tester\TestCase + public function testMetadataEmpty() + { + $container = $this->createContainer('metadata-empty'); + + /** @var Kdyby\Doctrine\EntityManager $default */ + $default = $container->getByType(\Kdyby\Doctrine\EntityManager::class); + $entityClasses = array_map(function (ClassMetadata $class) { + return $class->getName(); + }, $default->getMetadataFactory()->getAllMetadata()); + + Assert::contains(\KdybyTests\Doctrine\Models2\Foo::class, $entityClasses); + } + + + public function testProxyAutoloading() { $env = $_ENV + ['TEMP_DIR' => $scriptTempDir = TEMP_DIR . '/script']; diff --git a/tests/KdybyTests/Doctrine/config/metadata-empty.neon b/tests/KdybyTests/Doctrine/config/metadata-empty.neon new file mode 100644 index 00000000..2e3265c8 --- /dev/null +++ b/tests/KdybyTests/Doctrine/config/metadata-empty.neon @@ -0,0 +1,6 @@ +parameters: + appDir: %wwwDir%/Doctrine/models2 # appDir replacing required - AnnotationDriver::getAllClassNames() require problem + +kdyby.doctrine: + driver: pdo_sqlite + memory: true 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/