Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up doctrine deprecation warnings #977

Merged
3 commits merged into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
],
]
);
}
});
}
}
Loading