From 61119b2700332198348c503c265da8403eb00159 Mon Sep 17 00:00:00 2001 From: MAXakaWIZARD Date: Tue, 28 Jul 2015 20:45:05 +0300 Subject: [PATCH] Set current and default locale on prePersist event --- src/ORM/Translatable/TranslatableSubscriber.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ORM/Translatable/TranslatableSubscriber.php b/src/ORM/Translatable/TranslatableSubscriber.php index a7baa492..5ec002e4 100644 --- a/src/ORM/Translatable/TranslatableSubscriber.php +++ b/src/ORM/Translatable/TranslatableSubscriber.php @@ -298,6 +298,16 @@ private function isTranslation(ClassMetadata $classMetadata) } public function postLoad(LifecycleEventArgs $eventArgs) + { + $this->setLocales($eventArgs); + } + + public function prePersist(LifecycleEventArgs $eventArgs) + { + $this->setLocales($eventArgs); + } + + private function setLocales(LifecycleEventArgs $eventArgs) { $em = $eventArgs->getEntityManager(); $entity = $eventArgs->getEntity(); @@ -340,6 +350,7 @@ public function getSubscribedEvents() return [ Events::loadClassMetadata, Events::postLoad, + Events::prePersist, ]; } }