Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Model/Translatable/TranslatableMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Persistence\Proxy;
use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
use Knp\DoctrineBehaviors\Exception\TranslatableException;

Expand Down Expand Up @@ -104,6 +105,10 @@ public function setCurrentLocale(string $locale): void

public function getCurrentLocale(): string
{
if ($this instanceof Proxy && !$this->__isInitialized()) {
$this->__load();
}

return $this->currentLocale ?: $this->getDefaultLocale();
}

Expand All @@ -114,6 +119,10 @@ public function setDefaultLocale(string $locale): void

public function getDefaultLocale(): string
{
if ($this instanceof Proxy && !$this->__isInitialized()) {
$this->__load();
}

return $this->defaultLocale;
}

Expand Down