Skip to content

Commit

Permalink
Merge pull request #240 from MAXakaWIZARD/pr-locale-for-new-objects
Browse files Browse the repository at this point in the history
Set current and default locale on prePersist event
  • Loading branch information
docteurklein committed Sep 11, 2015
2 parents daa1ed7 + 61119b2 commit f2663e4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ORM/Translatable/TranslatableSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -340,6 +350,7 @@ public function getSubscribedEvents()
return [
Events::loadClassMetadata,
Events::postLoad,
Events::prePersist,
];
}
}

0 comments on commit f2663e4

Please sign in to comment.