Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #766: Ensure translatable is loaded when local variables are accessed #767

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Loading