Skip to content

Commit

Permalink
Initialize proxy objects if necessary (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex C <alex.canals@jkweb.ch>
  • Loading branch information
Alex--C and alex-canals authored Sep 13, 2023
1 parent b8e612c commit 09437e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Model/TranslatableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Persistence\Proxy;

/**
* @see TranslatableInterface
Expand Down Expand Up @@ -50,6 +51,10 @@ public function __construct()
*/
public function getTranslation(?string $locale = null): TranslationInterface
{
if ($this instanceof Proxy && !$this->__isInitialized()) {
$this->__load();
}

$locale = $locale ?: $this->currentLocale;
if (null === $locale) {
throw new \RuntimeException('No locale has been set and current locale is undefined.');
Expand Down

0 comments on commit 09437e2

Please sign in to comment.