Skip to content

Commit 753f9e8

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [DoctrineBridge] Fix compatibility with doctrine/orm 3 in Id generators Bump Symfony version to 6.0.5 Update VERSION for 6.0.4 Update CHANGELOG for 6.0.4 Bump Symfony version to 5.4.5 Update VERSION for 5.4.4 Update CHANGELOG for 5.4.4 Update VERSION for 5.3.15 Update CHANGELOG for 5.3.15 Remove 5.3 from PR template Bump Symfony version to 4.4.38 Update VERSION for 4.4.37 Update CONTRIBUTORS for 4.4.37 Update CHANGELOG for 4.4.37 [Process] Update PHPDoc to use proper placeholder syntax Fixed functional testing description
2 parents d643b35 + 8032808 commit 753f9e8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

IdGenerator/UlidGenerator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
15+
use Doctrine\ORM\EntityManagerInterface;
1516
use Doctrine\ORM\Id\AbstractIdGenerator;
1617
use Symfony\Component\Uid\Factory\UlidFactory;
1718
use Symfony\Component\Uid\Ulid;
@@ -25,7 +26,15 @@ public function __construct(UlidFactory $factory = null)
2526
$this->factory = $factory;
2627
}
2728

29+
/**
30+
* doctrine/orm < 2.11 BC layer.
31+
*/
2832
public function generate(EntityManager $em, $entity): Ulid
33+
{
34+
return $this->generateId($em, $entity);
35+
}
36+
37+
public function generateId(EntityManagerInterface $em, $entity): Ulid
2938
{
3039
if ($this->factory) {
3140
return $this->factory->create();

IdGenerator/UuidGenerator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\IdGenerator;
1313

1414
use Doctrine\ORM\EntityManager;
15+
use Doctrine\ORM\EntityManagerInterface;
1516
use Doctrine\ORM\Id\AbstractIdGenerator;
1617
use Symfony\Component\Uid\Factory\NameBasedUuidFactory;
1718
use Symfony\Component\Uid\Factory\RandomBasedUuidFactory;
@@ -30,7 +31,15 @@ public function __construct(UuidFactory $factory = null)
3031
$this->protoFactory = $this->factory = $factory ?? new UuidFactory();
3132
}
3233

34+
/**
35+
* doctrine/orm < 2.11 BC layer.
36+
*/
3337
public function generate(EntityManager $em, $entity): Uuid
38+
{
39+
return $this->generateId($em, $entity);
40+
}
41+
42+
public function generateId(EntityManagerInterface $em, $entity): Uuid
3443
{
3544
if (null !== $this->entityGetter) {
3645
if (\is_callable([$entity, $this->entityGetter])) {

0 commit comments

Comments
 (0)