<?php
namespace App\Entity\Web;
use App\Entity\Application\Store;
use App\Repository\Web\NewsStoreRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Behaviors\TranslatableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
/**
* @ORM\Table(name="web_news_stores")
* @ORM\Entity(repositoryClass=NewsStoreRepository::class)
* @ORM\EntityListeners({"App\Listener\EntityListener"})
*/
class NewsStore implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=News::class, inversedBy="newsStores")
* @ORM\JoinColumn(nullable=false)
*/
private $news;
/**
* @ORM\ManyToOne(targetEntity=Store::class)
* @ORM\JoinColumn(nullable=false)
*/
private $store;
public function __construct()
{
/*$this->translations= new ArrayCollection([
new NewsStoreTranslation('cs'),
new NewsStoreTranslation('de'),
new NewsStoreTranslation('en')
]);*/
/*$this->setDefaultLocale(\Locale::getDefault());
$trans = new NewsStoreTranslation('cs');
$this->addTranslation($trans);
$trans = new NewsStoreTranslation('de');
$this->addTranslation($trans);
$trans = new NewsStoreTranslation('en');
$this->addTranslation($trans);
$this->mergeNewTranslations();*/
}
public function __call($method, $arguments)
{
$ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
if(empty($ret)) {
$ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
}
return $ret;
}
public function getId(): ?int
{
return $this->id;
}
public function getNews(): ?News
{
return $this->news;
}
public function setNews(?News $news): self
{
$this->news = $news;
return $this;
}
public function getStore(): ?Store
{
return $this->store;
}
public function setStore(?Store $store): self
{
$this->store = $store;
return $this;
}
}