From 3242af8c62219dbbe6a9db258e8514b29d4e55d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Wed, 2 Jun 2021 14:56:03 +0200 Subject: [PATCH] Make configuration error message better understandable (#1367) --- DependencyInjection/Configuration.php | 4 ++-- Tests/DependencyInjection/AbstractDoctrineExtensionTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 6ff8882ef..4fa5f2971 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -94,7 +94,7 @@ private function addDbalSection(ArrayNodeDefinition $node): void } if ($connection && $hasExplicitlyDefinedConnectionsAtLeastOnce) { - throw new InvalidArgumentException('Either explicitly define DBAL connections in all doctrine-bundle configuration files, or in none of them'); + throw new InvalidArgumentException('Seems like you have configured multiple "dbal" connections. You need to use the long configuration syntax in every doctrine configuration file, or in none of them.'); } $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default'; @@ -413,7 +413,7 @@ private function addOrmSection(ArrayNodeDefinition $node): void } if ($entityManager && $hasExplicitlyDefinedEntityManagersAtLeastOnce) { - throw new InvalidArgumentException('Either explicitly define entity managers in all doctrine-bundle configuration files, or in none of them'); + throw new InvalidArgumentException('Seems like you have configured multiple "entity_managers". You need to use the long configuration syntax in every doctrine configuration file, or in none of them.'); } $v['default_entity_manager'] = isset($v['default_entity_manager']) ? (string) $v['default_entity_manager'] : 'default'; diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 1ee2210e4..83f021a01 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -218,13 +218,13 @@ class_exists(PrimaryReadReplicaConnection::class) ? public function testMixedUseOfSimplifiedAndMultipleConnectionsStyleIsInvalid(): void { - $this->expectExceptionObject(new InvalidArgumentException('Either explicitly define DBAL connections in all doctrine-bundle configuration files, or in none of them')); + $this->expectExceptionObject(new InvalidArgumentException('Seems like you have configured multiple "dbal" connections. You need to use the long configuration syntax in every doctrine configuration file, or in none of them.')); $this->loadContainer('dbal_service_{single,multiple}_connectio{n,ns}'); } public function testMixedUseOfSimplifiedAndMultipleEntityManagersStyleIsInvalid(): void { - $this->expectExceptionObject(new InvalidArgumentException('Either explicitly define entity managers in all doctrine-bundle configuration files, or in none of them')); + $this->expectExceptionObject(new InvalidArgumentException('Seems like you have configured multiple "entity_managers". You need to use the long configuration syntax in every doctrine configuration file, or in none of them.')); $this->loadContainer('orm_service_{simple_single,multiple}_entity_manage{r,rs}'); }