diff --git a/src/Doctrine/PolyglotListener.php b/src/Doctrine/PolyglotListener.php index b83b02d..eb4b67e 100644 --- a/src/Doctrine/PolyglotListener.php +++ b/src/Doctrine/PolyglotListener.php @@ -94,7 +94,7 @@ private function injectPersistentTranslatables(EntityManager $entityManager, obj public function preFlush(PreFlushEventArgs $event): void { - $em = $event->getEntityManager(); + $em = $event->getObjectManager(); foreach ($this->entitiesWithTranslatables as $key => $weakRef) { $object = $weakRef->get(); @@ -146,21 +146,21 @@ private function loadTranslationMetadataForClass($className, EntityManager $em): } $metadataFactory = $em->getMetadataFactory(); - $cacheDriver = $em->getConfiguration()->getMetadataCacheImpl(); + $cache = $em->getConfiguration()->getMetadataCache(); - if ($cacheDriver) { - if (($data = $cacheDriver->fetch($className.self::CACHE_SALT)) !== false) { - if (null === $data) { - $this->translatedClasses[$className] = null; + if ($cache?->hasItem($className.self::CACHE_SALT)) { + $item = $cache->getItem($className.self::CACHE_SALT); + $data = $item->get(); + if (null === $data) { + $this->translatedClasses[$className] = null; - return null; - } else { - $wakeup = TranslatableClassMetadata::wakeup($data); - $wakeup->setLogger($this->logger); - $this->translatedClasses[$className] = $wakeup; + return null; + } else { + $wakeup = TranslatableClassMetadata::wakeup($data); + $wakeup->setLogger($this->logger); + $this->translatedClasses[$className] = $wakeup; - return $wakeup; - } + return $wakeup; } } @@ -173,7 +173,11 @@ private function loadTranslationMetadataForClass($className, EntityManager $em): } // Save if cache driver available - $cacheDriver?->save($className.self::CACHE_SALT, $meta?->sleep()); + if ($cache) { + $item = $cache->getItem($className.self::CACHE_SALT); + $item->set($meta?->sleep()); + $cache->save($item); + } return $meta; } diff --git a/src/Doctrine/TranslatableStringType.php b/src/Doctrine/TranslatableStringType.php index 7c5b565..e0e1b15 100644 --- a/src/Doctrine/TranslatableStringType.php +++ b/src/Doctrine/TranslatableStringType.php @@ -21,7 +21,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st return $platform->getClobTypeDeclarationSQL($column); } - return $platform->getVarcharTypeDeclarationSQL($column); + return $platform->getStringTypeDeclarationSQL($column); } public function getName(): string