src/Entity/Web/NewsStore.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Web;
  3. use App\Entity\Application\Store;
  4. use App\Repository\Web\NewsStoreRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Behaviors\TranslatableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. /**
  10. * @ORM\Table(name="web_news_stores")
  11. * @ORM\Entity(repositoryClass=NewsStoreRepository::class)
  12. * @ORM\EntityListeners({"App\Listener\EntityListener"})
  13. */
  14. class NewsStore implements TranslatableInterface
  15. {
  16. use TranslatableTrait;
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. */
  22. private $id;
  23. /**
  24. * @ORM\ManyToOne(targetEntity=News::class, inversedBy="newsStores")
  25. * @ORM\JoinColumn(nullable=false)
  26. */
  27. private $news;
  28. /**
  29. * @ORM\ManyToOne(targetEntity=Store::class)
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. private $store;
  33. public function __construct()
  34. {
  35. /*$this->translations= new ArrayCollection([
  36. new NewsStoreTranslation('cs'),
  37. new NewsStoreTranslation('de'),
  38. new NewsStoreTranslation('en')
  39. ]);*/
  40. /*$this->setDefaultLocale(\Locale::getDefault());
  41. $trans = new NewsStoreTranslation('cs');
  42. $this->addTranslation($trans);
  43. $trans = new NewsStoreTranslation('de');
  44. $this->addTranslation($trans);
  45. $trans = new NewsStoreTranslation('en');
  46. $this->addTranslation($trans);
  47. $this->mergeNewTranslations();*/
  48. }
  49. public function __call($method, $arguments)
  50. {
  51. $ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
  52. if(empty($ret)) {
  53. $ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
  54. }
  55. return $ret;
  56. }
  57. public function getId(): ?int
  58. {
  59. return $this->id;
  60. }
  61. public function getNews(): ?News
  62. {
  63. return $this->news;
  64. }
  65. public function setNews(?News $news): self
  66. {
  67. $this->news = $news;
  68. return $this;
  69. }
  70. public function getStore(): ?Store
  71. {
  72. return $this->store;
  73. }
  74. public function setStore(?Store $store): self
  75. {
  76. $this->store = $store;
  77. return $this;
  78. }
  79. }