Skip to content

Commit

Permalink
Clean up doctrine deprecation warnings (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
debounced authored Aug 3, 2024
1 parent ec138cf commit bb4d7e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 1 addition & 3 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ doctrine:
JSONB_CONTAINS: Scienta\DoctrineJsonFunctions\Query\AST\Functions\Postgresql\JsonbContains
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
# This option needs to be set to 'false', otherwise PHP class inheritance will fail with
# a separate sequence number generator table in PostgreSQL for each child class
report_fields_where_declared: false
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
Expand Down
23 changes: 23 additions & 0 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

namespace App;

use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\ORM\Mapping\ClassMetadata;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

Expand All @@ -27,4 +31,23 @@ protected function configureRoutes(RoutingConfigurator $routes): void
$routes->import($projectDir.'/config/{routes}.php');
}
}

#[Override]
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new class() implements CompilerPassInterface {
public function process(ContainerBuilder $container): void
{
$container->getDefinition('doctrine.orm.default_configuration')
->addMethodCall(
'setIdentityGenerationPreferences',
[
[
PostgreSQLPlatform::class => ClassMetadata::GENERATOR_TYPE_SEQUENCE,
],
]
);
}
});
}
}

0 comments on commit bb4d7e2

Please sign in to comment.