Website/app/config/packages/doctrine.php

72 lines
2.4 KiB
PHP
Raw Normal View History

2024-04-22 20:26:40 +00:00
<?php
declare(strict_types=1);
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('doctrine', [
'dbal' => [
'url' => '%env(resolve:DATABASE_URL)%',
'profiling_collect_backtrace' => '%kernel.debug%',
],
'orm' => [
'auto_generate_proxy_classes' => true,
'enable_lazy_ghost_objects' => true,
'report_fields_where_declared' => true,
'validate_xml_mapping' => true,
'naming_strategy' => 'doctrine.orm.naming_strategy.underscore_number_aware',
'auto_mapping' => true,
'mappings' => [
'App' => [
'type' => 'attribute',
'is_bundle' => false,
'dir' => '%kernel.project_dir%/src',
'prefix' => 'App',
'alias' => 'App',
],
],
],
]);
if ($containerConfigurator->env() === 'test') {
$containerConfigurator->extension('doctrine', [
'dbal' => [
'connections' => [
'default' => [
'dbname_suffix' => '%env(TEST_TOKEN)%',
'use_savepoints' => true,
],
],
],
]);
}
if ($containerConfigurator->env() === 'prod') {
$containerConfigurator->extension('doctrine', [
'orm' => [
'auto_generate_proxy_classes' => false,
'proxy_dir' => '%kernel.build_dir%/doctrine/orm/Proxies',
'query_cache_driver' => [
'type' => 'pool',
'pool' => 'doctrine.system_cache_pool',
],
'result_cache_driver' => [
'type' => 'pool',
'pool' => 'doctrine.result_cache_pool',
],
],
]);
$containerConfigurator->extension('framework', [
'cache' => [
'pools' => [
'doctrine.result_cache_pool' => [
'adapter' => 'cache.app',
],
'doctrine.system_cache_pool' => [
'adapter' => 'cache.system',
],
],
],
]);
}
};