Skip to content

Commit

Permalink
Fix direct doctrine/* deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Apr 4, 2024
1 parent ca1a738 commit a31b939
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
32 changes: 18 additions & 14 deletions src/Doctrine/PolyglotListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/TranslatableStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a31b939

Please sign in to comment.