Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 53877b8

Browse filesBrowse files
committed
Add support for doctrine/persistence 4
v4 provides a guarantee that ManagerRegistry::getManager() returns an entity manager (as opposed to null).
1 parent 2fd8b08 commit 53877b8
Copy full SHA for 53877b8

File tree

6 files changed

+16
-2
lines changed
Filter options

6 files changed

+16
-2
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ext-xml": "*",
4040
"friendsofphp/proxy-manager-lts": "^1.0.2",
4141
"doctrine/event-manager": "^1.2|^2",
42-
"doctrine/persistence": "^2.5|^3.1",
42+
"doctrine/persistence": "^2.5|^3.1|^4",
4343
"twig/twig": "^2.13|^3.0.4",
4444
"psr/cache": "^2.0|^3.0",
4545
"psr/clock": "^1.0",

‎src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/ArgumentResolver/EntityValueResolver.php
+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array
5050
if (!$options->class || $options->disabled) {
5151
return [];
5252
}
53+
// doctrine/persistence < 4 compat
5354
if (!$manager = $this->getManager($options->objectManager, $options->class)) {
5455
return [];
5556
}

‎src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/ArgumentResolver/EntityValueResolverTest.php
+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public function testResolveWithoutAttribute()
5454

5555
public function testResolveWithoutManager()
5656
{
57+
if (method_exists(ObjectManager::class, 'isUninitializedObject')) {
58+
$this->markTestSkipped('This test is not applicable to doctrine/persistence 4');
59+
}
60+
5761
$registry = $this->createRegistry(null);
5862
$resolver = new EntityValueResolver($registry);
5963

‎src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+8
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ public function testValidateUniquenessWithArrayValue()
614614

615615
public function testDedicatedEntityManagerNullObject()
616616
{
617+
if (method_exists(ObjectManager::class, 'isUninitializedObject')) {
618+
$this->markTestSkipped('This test is not applicable to persistence 4');
619+
}
620+
617621
$constraint = new UniqueEntity([
618622
'message' => 'myMessage',
619623
'fields' => ['name'],
@@ -635,6 +639,10 @@ public function testDedicatedEntityManagerNullObject()
635639

636640
public function testEntityManagerNullObject()
637641
{
642+
if (method_exists(ObjectManager::class, 'isUninitializedObject')) {
643+
$this->markTestSkipped('This test is not applicable to doctrine/persistence 4');
644+
}
645+
638646
$constraint = new UniqueEntity([
639647
'message' => 'myMessage',
640648
'fields' => ['name'],

‎src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function validate(mixed $entity, Constraint $constraint)
7171
if ($constraint->em) {
7272
$em = $this->registry->getManager($constraint->em);
7373

74+
// doctrine/persistence < 4 compat
7475
if (!$em) {
7576
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
7677
}

‎src/Symfony/Bridge/Doctrine/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/composer.json
+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.1",
2020
"doctrine/event-manager": "^1.2|^2",
21-
"doctrine/persistence": "^2.5|^3.1",
21+
"doctrine/persistence": "^2.5|^3.1|^4",
2222
"symfony/deprecation-contracts": "^2.5|^3",
2323
"symfony/polyfill-ctype": "~1.8",
2424
"symfony/polyfill-mbstring": "~1.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.