Skip to content

Navigation Menu

Sign in
Appearance settings

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 39d9e48

Browse filesBrowse files
committed
[DoctrineBridge] Fix compatibility with doctrine/orm 3 in Id generators
1 parent d6cf082 commit 39d9e48
Copy full SHA for 39d9e48

File tree

2 files changed

+18
-0
lines changed
Filter options

2 files changed

+18
-0
lines changed

‎src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php
+9Lines 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();

‎src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php
+9Lines 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\UuidFactory;
1718
use Symfony\Component\Uid\Uuid;
@@ -27,7 +28,15 @@ public function __construct(UuidFactory $factory = null)
2728
$this->protoFactory = $this->factory = $factory ?? new UuidFactory();
2829
}
2930

31+
/**
32+
* doctrine/orm < 2.11 BC layer
33+
*/
3034
public function generate(EntityManager $em, $entity): Uuid
35+
{
36+
return $this->generateId($em, $entity);
37+
}
38+
39+
public function generateId(EntityManagerInterface $em, $entity): Uuid
3140
{
3241
if (null !== $this->entityGetter) {
3342
if (\is_callable([$entity, $this->entityGetter])) {

0 commit comments

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