Skip to content

Commit 53877b8

Browse 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

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy