Skip to content

Commit be47be4

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

File tree

10 files changed

+60
-42
lines changed

10 files changed

+60
-42
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,21 @@ 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+
dependencies: 'lowest'
68+
- php-version: '7.4'
69+
sf-version: '5.4'
70+
dependencies: 'highest'
71+
- php-version: '8.4'
72+
sf-version: '7.3'
73+
dependencies: 'lowest'
74+
- php-version: '8.4'
75+
sf-version: '7.3'
76+
dependencies: 'highest'
6477

65-
name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)
78+
name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)${{ matrix.dependencies && format(' ({0})', matrix.dependencies) || '' }}
6679
steps:
6780
- name: Checkout code
6881
uses: actions/checkout@v5
@@ -85,15 +98,15 @@ 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
92105

93106
- name: Upload coverage file
94107
uses: actions/upload-artifact@v4
95108
with:
96-
name: 'phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-coverage'
109+
name: "phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}${{ matrix.dependencies && format('-{0}', matrix.dependencies) || '' }}-coverage"
97110
path: 'coverage.xml'
98111

99112
code-style:

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
->setFinder($finder)
1414
->setRules([
1515
'@Symfony' => true,
16-
'@PHP80Migration:risky' => true,
16+
'@PHP8x0Migration:risky' => true,
1717
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
1818
'global_namespace_import' => [
1919
'import_classes' => false,

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: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
88
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
9-
use Doctrine\ORM\Configuration;
109
use Doctrine\ORM\Mapping\LegacyReflectionFields;
10+
use Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter;
1111
use Meilisearch\Bundle\MeilisearchBundle;
1212
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
1313
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@@ -29,18 +29,30 @@ public function registerBundles(): iterable
2929

3030
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
3131
{
32+
$loader->load(__DIR__.'/config/framework.yaml');
33+
34+
$doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class);
35+
3236
if (PHP_VERSION_ID >= 80000) {
33-
if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
34-
$loader->load(__DIR__.'/config/config.yaml');
37+
if ($doctrineBundleV3) {
38+
$loader->load(__DIR__.'/config/doctrine.yaml');
39+
} elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
40+
$loader->load(__DIR__.'/config/doctrine_v2.yaml');
3541
} else {
36-
$loader->load(__DIR__.'/config/config_old_proxy.yaml');
42+
$loader->load(__DIR__.'/config/doctrine_old_proxy.yaml');
3743
}
3844
} else {
39-
$loader->load(__DIR__.'/config/config_php7.yaml');
45+
$container->prependExtensionConfig('framework', [
46+
'annotations' => true,
47+
'serializer' => ['enable_annotations' => true],
48+
'router' => ['utf8' => true],
49+
]);
50+
51+
$loader->load(__DIR__.'/config/doctrine_php7.yaml');
4052
}
4153
$loader->load(__DIR__.'/config/meilisearch.yaml');
4254

43-
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
55+
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) {
4456
$container->prependExtensionConfig('doctrine', [
4557
'orm' => [
4658
'report_fields_where_declared' => true,
@@ -49,15 +61,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
4961
]);
5062
}
5163

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-
}
60-
6164
if (class_exists(EntityValueResolver::class)) {
6265
$container->prependExtensionConfig('doctrine', [
6366
'orm' => [

tests/baseline-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
%Calling Doctrine\\ORM\\Configuration::getAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0%
99
%Calling Doctrine\\ORM\\Configuration::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0%
1010
%Since doctrine/doctrine-bundle 2.16: Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated%
11+
%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0.%

tests/config/doctrine.yaml

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

tests/config/config_old_proxy.yaml renamed to tests/config/doctrine_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/config.yaml renamed to tests/config/doctrine_v2.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
@@ -15,7 +10,6 @@ doctrine:
1510
orm:
1611
enable_native_lazy_objects: true
1712
auto_generate_proxy_classes: false
18-
report_fields_where_declared: true
1913
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
2014
auto_mapping: true
2115
mappings:

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)