Skip to content

Commit 676fc8d

Browse files
committed
Refactor Doctrine configuration for compatibility with version constraints
1 parent 06aa7f8 commit 676fc8d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/LiveComponent/tests/Fixtures/Kernel.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Composer\InstalledVersions;
1515
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
16-
use Doctrine\ORM\Mapping\AssociationMapping;
1716
use Psr\Log\NullLogger;
1817
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1918
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
@@ -81,7 +80,7 @@ public function registerBundles(): iterable
8180
protected function build(ContainerBuilder $container): void
8281
{
8382
// workaround https://github.com/symfony/symfony/issues/50322
84-
$container->addCompilerPass(new class() implements CompilerPassInterface {
83+
$container->addCompilerPass(new class implements CompilerPassInterface {
8584
public function process(ContainerBuilder $container): void
8685
{
8786
$container->removeDefinition('doctrine.orm.listeners.pdo_session_handler_schema_listener');
@@ -197,11 +196,19 @@ protected function configureContainer(ContainerConfigurator $c): void
197196

198197
// https://github.com/doctrine/DoctrineBundle/pull/1661
199198
if (version_compare($doctrineBundleVersion, '2.9.0', '>=')) {
200-
$doctrineConfig['orm']['report_fields_where_declared'] = true;
201199
$doctrineConfig['orm']['validate_xml_mapping'] = true;
202200
$doctrineConfig['dbal']['schema_manager_factory'] = 'doctrine.dbal.default_schema_manager_factory';
203201
}
204202

203+
// https://github.com/doctrine/DoctrineBundle/pull/1661
204+
// https://github.com/doctrine/DoctrineBundle/pull/1962
205+
if (
206+
version_compare($doctrineBundleVersion, '2.9.0', '>=')
207+
&& version_compare($doctrineBundleVersion, '3.0.0', '<')
208+
) {
209+
$doctrineConfig['orm']['report_fields_where_declared'] = true;
210+
}
211+
205212
if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=') && version_compare($doctrineBundleVersion, '4.0.0', '<')) {
206213
$doctrineConfig['orm']['enable_native_lazy_objects'] = true;
207214
}

0 commit comments

Comments
 (0)