Skip to content

Commit 0a4e91a

Browse files
committed
Add support for doctrine bundle v3
1 parent 752afde commit 0a4e91a

File tree

8 files changed

+88
-47
lines changed

8 files changed

+88
-47
lines changed

.github/workflows/tests.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ jobs:
6161
sf-version: '7.2'
6262
- php-version: '8.1'
6363
sf-version: '7.2'
64+
include:
65+
- php-version: '7.4'
66+
sf-version: '5.4'
67+
deps: 'lowest'
68+
- php-version: '7.4'
69+
sf-version: '5.4'
70+
deps: 'highest'
71+
- php-version: '8.4'
72+
sf-version: '7.3'
73+
deps: 'lowest'
74+
- php-version: '8.4'
75+
sf-version: '7.3'
76+
deps: 'highest'
6477

6578
name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)
6679
steps:
@@ -85,7 +98,7 @@ jobs:
8598
env:
8699
SYMFONY_REQUIRE: ${{ matrix.sf-version }}.*
87100
with:
88-
dependency-versions: 'highest'
101+
dependency-versions: "${{ matrix.dependencies }}"
89102

90103
- name: Run test suite
91104
run: composer test:unit -- --coverage-clover coverage.xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"require": {
2121
"php": "^7.4|^8.0",
2222
"ext-json": "*",
23-
"doctrine/doctrine-bundle": "^2.10",
23+
"doctrine/doctrine-bundle": "^2.10 || ^3.0",
2424
"meilisearch/meilisearch-php": "^1.0.0",
2525
"symfony/config": "^5.4 || ^6.0 || ^7.0",
2626
"symfony/dependency-injection": "^5.4.17 || ^6.0 || ^7.0",

tests/Kernel.php

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
99
use Doctrine\ORM\Configuration;
1010
use Doctrine\ORM\Mapping\LegacyReflectionFields;
11+
use Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter;
1112
use Meilisearch\Bundle\MeilisearchBundle;
1213
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
1314
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -29,44 +30,63 @@ public function registerBundles(): iterable
2930

3031
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
3132
{
33+
$loader->load(__DIR__.'/config/framework.yaml');
34+
35+
$doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class);
36+
3237
if (PHP_VERSION_ID >= 80000) {
33-
if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
38+
if ($doctrineBundleV3) {
3439
$loader->load(__DIR__.'/config/config.yaml');
40+
} elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
41+
$loader->load(__DIR__.'/config/config_doctrine_v2.yaml');
3542
} else {
3643
$loader->load(__DIR__.'/config/config_old_proxy.yaml');
3744
}
3845
} else {
39-
$loader->load(__DIR__.'/config/config_php7.yaml');
40-
}
41-
$loader->load(__DIR__.'/config/meilisearch.yaml');
42-
43-
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
44-
$container->prependExtensionConfig('doctrine', [
45-
'orm' => [
46-
'report_fields_where_declared' => true,
47-
'validate_xml_mapping' => true,
48-
],
46+
$container->prependExtensionConfig('framework', [
47+
'annotations' => true,
48+
'serializer' => ['enable_annotations' => true],
49+
'router' => ['utf8' => true],
4950
]);
50-
}
5151

52-
// @phpstan-ignore-next-line
53-
if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) {
54-
$container->prependExtensionConfig('doctrine', [
55-
'orm' => [
56-
'enable_lazy_ghost_objects' => true,
57-
],
58-
]);
59-
}
52+
$loader->load(__DIR__.'/config/doctrine_php7.yaml');
6053

61-
if (class_exists(EntityValueResolver::class)) {
62-
$container->prependExtensionConfig('doctrine', [
63-
'orm' => [
64-
'controller_resolver' => [
65-
'auto_mapping' => false,
54+
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
55+
$container->prependExtensionConfig('doctrine', [
56+
'orm' => [
57+
'report_fields_where_declared' => true,
58+
'validate_xml_mapping' => true,
6659
],
67-
],
68-
]);
60+
]);
61+
}
6962
}
63+
$loader->load(__DIR__.'/config/meilisearch.yaml');
64+
65+
$doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class);
66+
67+
// if (!class_exists(BlacklistSchemaAssetFilter::class)) {
68+
// $container->prependExtensionConfig('doctrine', [
69+
// 'orm' => [
70+
// 'enable_native_lazy_objects' => true,
71+
// ],
72+
// ]);
73+
// } elseif (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100 && !$doctrineBundleV3) {
74+
// $container->prependExtensionConfig('doctrine', [
75+
// 'orm' => [
76+
// 'enable_lazy_ghost_objects' => true,
77+
// ],
78+
// ]);
79+
// }
80+
81+
// if (class_exists(EntityValueResolver::class)) {
82+
// $container->prependExtensionConfig('doctrine', [
83+
// 'orm' => [
84+
// 'controller_resolver' => [
85+
// 'auto_mapping' => false,
86+
// ],
87+
// ],
88+
// ]);
89+
// }
7090

7191
// @phpstan-ignore-next-line
7292
if (Kernel::VERSION_ID >= 60400) {

tests/config/config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ doctrine:
1313
types:
1414
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
1515
orm:
16-
enable_native_lazy_objects: true
17-
auto_generate_proxy_classes: false
18-
report_fields_where_declared: true
1916
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
2017
auto_mapping: true
2118
mappings:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
doctrine:
2+
dbal:
3+
default_connection: default
4+
connections:
5+
default:
6+
driver: pdo_sqlite
7+
path: '%kernel.cache_dir%/test.sqlite'
8+
types:
9+
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
10+
orm:
11+
enable_native_lazy_objects: true
12+
auto_generate_proxy_classes: false
13+
report_fields_where_declared: true
14+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
15+
auto_mapping: true
16+
mappings:
17+
App:
18+
is_bundle: false
19+
type: attribute
20+
dir: '%kernel.project_dir%/tests/Entity'
21+
prefix: 'Meilisearch\Bundle\Tests\Entity'
22+
alias: App

tests/config/config_old_proxy.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
framework:
2-
test: true
3-
secret: 67d829bf61dc5f87a73fd814e2c9f629
4-
http_method_override: false
5-
61
doctrine:
72
dbal:
83
default_connection: default

tests/config/config_php7.yaml renamed to tests/config/doctrine_php7.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
framework:
2-
test: true
3-
secret: 67d829bf61dc5f87a73fd814e2c9f629
4-
http_method_override: false
5-
annotations: true
6-
serializer:
7-
enable_annotations: true
8-
router:
9-
utf8: true
10-
111
doctrine:
122
dbal:
133
default_connection: default

tests/config/framework.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework:
2+
test: true
3+
secret: 67d829bf61dc5f87a73fd814e2c9f629
4+
http_method_override: false

0 commit comments

Comments
 (0)