Skip to content

Commit 9c4efad

Browse files
committed
Add support for doctrine bundle v3
1 parent 752afde commit 9c4efad

File tree

8 files changed

+71
-32
lines changed

8 files changed

+71
-32
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: 31 additions & 11 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,18 +30,30 @@ 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');
46+
$container->prependExtensionConfig('framework', [
47+
'annotations' => true,
48+
'serializer' => ['enable_annotations' => true],
49+
'router' => ['utf8' => true],
50+
]);
51+
52+
$loader->load(__DIR__.'/config/doctrine_php7.yaml');
4053
}
4154
$loader->load(__DIR__.'/config/meilisearch.yaml');
4255

43-
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
56+
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) {
4457
$container->prependExtensionConfig('doctrine', [
4558
'orm' => [
4659
'report_fields_where_declared' => true,
@@ -49,14 +62,21 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
4962
]);
5063
}
5164

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-
}
65+
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+
// }
6080

6181
if (class_exists(EntityValueResolver::class)) {
6282
$container->prependExtensionConfig('doctrine', [

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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
14+
auto_mapping: true
15+
mappings:
16+
App:
17+
is_bundle: false
18+
type: attribute
19+
dir: '%kernel.project_dir%/tests/Entity'
20+
prefix: 'Meilisearch\Bundle\Tests\Entity'
21+
alias: App

tests/config/config_old_proxy.yaml

Lines changed: 0 additions & 6 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
@@ -14,7 +9,6 @@ doctrine:
149
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
1510
orm:
1611
auto_generate_proxy_classes: true
17-
report_fields_where_declared: true
1812
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
1913
auto_mapping: true
2014
mappings:

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)