From c0eede4f8333bc0f963cb5850582ed544333fe26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Sun, 30 Jan 2022 11:53:34 +0100 Subject: [PATCH] [DoctrineBridge] Fix compatibility with doctrine/orm 3 in Id generators --- .../Bridge/Doctrine/IdGenerator/UlidGenerator.php | 9 +++++++++ .../Bridge/Doctrine/IdGenerator/UuidGenerator.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php index b3923d11c051a..74dc9ec250f2b 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Doctrine\IdGenerator; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\Factory\UlidFactory; use Symfony\Component\Uid\Ulid; @@ -25,7 +26,15 @@ public function __construct(UlidFactory $factory = null) $this->factory = $factory; } + /** + * doctrine/orm < 2.11 BC layer. + */ public function generate(EntityManager $em, $entity): Ulid + { + return $this->generateId($em, $entity); + } + + public function generateId(EntityManagerInterface $em, $entity): Ulid { if ($this->factory) { return $this->factory->create(); diff --git a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php index 272989a834ab7..af31f109fe66e 100644 --- a/src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php +++ b/src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Doctrine\IdGenerator; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Id\AbstractIdGenerator; use Symfony\Component\Uid\Factory\UuidFactory; use Symfony\Component\Uid\Uuid; @@ -27,7 +28,15 @@ public function __construct(UuidFactory $factory = null) $this->protoFactory = $this->factory = $factory ?? new UuidFactory(); } + /** + * doctrine/orm < 2.11 BC layer. + */ public function generate(EntityManager $em, $entity): Uuid + { + return $this->generateId($em, $entity); + } + + public function generateId(EntityManagerInterface $em, $entity): Uuid { if (null !== $this->entityGetter) { if (\is_callable([$entity, $this->entityGetter])) { 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