<?php
namespace App\Entity;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Swift_Mailer;
class TranslatedEntity
{
protected $languageId;
protected $currentLocale;
public function getLanguageId() {
return $this->languageId;
}
public function setLanguageId($languageId) {
$this->languageId = $languageId;
}
public function setCurrentLocale($locale) {
$this->currentLocale = $locale;
}
public function translate($languageCode='fr')
{
$languageId = $languageCode=='fr'?4:1;
$this->setLanguageId($languageId);
$this->setCurrentLocale($languageCode);
}
public function __call($method, $arguments)
{
$translatedMethod = 'get'.$this->tranlatedEntity;
$translatedObject = call_user_func_array(
[$this, $translatedMethod],[]
);
return \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor()->getValue($translatedObject, $method);
}
}