src/Entity/Web/News.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Web;
  3. use App\Repository\Web\NewsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  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")
  11. * @ORM\Entity(repositoryClass=NewsRepository::class)
  12. * @ORM\EntityListeners({"App\Listener\EntityListener"})
  13. */
  14. class News implements TranslatableInterface
  15. {
  16. use TranslatableTrait;
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. */
  22. private int $id;
  23. /**
  24. * @ORM\Column(type="datetime")
  25. */
  26. private $datePublic;
  27. /**
  28. * @ORM\Column(type="datetime", nullable=true)
  29. */
  30. private $dateFrom = null;
  31. /**
  32. * @ORM\Column(type="datetime", nullable=true)
  33. */
  34. private $dateTo = null;
  35. /**
  36. * @ORM\Column(type="boolean")
  37. */
  38. private $isActive = true;
  39. /**
  40. * @ORM\Column(type="boolean")
  41. */
  42. private $isPopup = false;
  43. /**
  44. * @ORM\Column(type="datetime")
  45. */
  46. private $createts;
  47. /**
  48. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  49. * @ORM\JoinColumn(nullable=false)
  50. */
  51. private $createUser;
  52. /**
  53. * @ORM\Column(type="datetime", nullable=true)
  54. */
  55. private $editts;
  56. /**
  57. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  58. */
  59. private $editUser;
  60. /**
  61. * @ORM\OneToMany(targetEntity=NewsStore::class,cascade={"all"}, mappedBy="news", orphanRemoval=true)
  62. */
  63. private $newsStores;
  64. public function __construct()
  65. {
  66. //$this->setDefaultLocale(\Locale::getDefault());
  67. //$trans = new NewsTranslation($this->getDefaultLocale());
  68. //$this->addTranslation($trans);
  69. if($this->getDatePublic() === null){
  70. $this->setDatePublic(new \DateTime());
  71. $this->setDateFrom(new \DateTime());
  72. $this->setDateTo(new \DateTime());
  73. }
  74. $this->newsStores = new ArrayCollection();
  75. }
  76. public function getId(): ?int
  77. {
  78. return $this->id;
  79. }
  80. public function isIsActive(): ?bool
  81. {
  82. return $this->isActive;
  83. }
  84. public function setIsActive(bool $isActive): self
  85. {
  86. $this->isActive = $isActive;
  87. return $this;
  88. }
  89. public function __call($method, $arguments)
  90. {
  91. $ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
  92. if(empty($ret)) {
  93. $ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
  94. }
  95. return $ret;
  96. }
  97. /**
  98. * @return mixed
  99. */
  100. public function getCreatets()
  101. {
  102. return $this->createts;
  103. }
  104. /**
  105. * @param mixed $createts
  106. */
  107. public function setCreatets($createts): void
  108. {
  109. $this->createts = $createts;
  110. }
  111. /**
  112. * @return mixed
  113. */
  114. public function getCreateUser()
  115. {
  116. return $this->createUser;
  117. }
  118. /**
  119. * @param mixed $createUser
  120. */
  121. public function setCreateUser($createUser): void
  122. {
  123. $this->createUser = $createUser;
  124. }
  125. /**
  126. * @return mixed
  127. */
  128. public function getEditts()
  129. {
  130. return $this->editts;
  131. }
  132. /**
  133. * @param mixed $editts
  134. */
  135. public function setEditts($editts): void
  136. {
  137. $this->editts = $editts;
  138. }
  139. /**
  140. * @return mixed
  141. */
  142. public function getEditUser()
  143. {
  144. return $this->editUser;
  145. }
  146. /**
  147. * @param mixed $editUser
  148. */
  149. public function setEditUser($editUser): void
  150. {
  151. $this->editUser = $editUser;
  152. }
  153. /**
  154. * @return mixed
  155. */
  156. public function getDatePublic()
  157. {
  158. return $this->datePublic;
  159. }
  160. /**
  161. * @param mixed $datePublic
  162. */
  163. public function setDatePublic($datePublic): void
  164. {
  165. $this->datePublic = $datePublic;
  166. }
  167. /**
  168. * @return bool
  169. */
  170. public function isPopup(): bool
  171. {
  172. return $this->isPopup;
  173. }
  174. /**
  175. * @param bool $isPopup
  176. */
  177. public function setIsPopup(bool $isPopup): void
  178. {
  179. $this->isPopup = $isPopup;
  180. }
  181. /**
  182. * @return Collection<int, NewsStore>
  183. */
  184. public function getNewsStores(): Collection
  185. {
  186. return $this->newsStores;
  187. }
  188. public function addNewsStore(NewsStore $newsStore): self
  189. {
  190. if (!$this->newsStores->contains($newsStore)) {
  191. $this->newsStores[] = $newsStore;
  192. $newsStore->setNews($this);
  193. }
  194. return $this;
  195. }
  196. public function removeNewsStore(NewsStore $newsStore): self
  197. {
  198. if ($this->newsStores->removeElement($newsStore)) {
  199. // set the owning side to null (unless already changed)
  200. if ($newsStore->getNews() === $this) {
  201. $newsStore->setNews(null);
  202. }
  203. }
  204. return $this;
  205. }
  206. /**
  207. * Get DateFrom
  208. *
  209. * @return mixed
  210. */
  211. public function getDateFrom()
  212. {
  213. return $this->dateFrom;
  214. }
  215. /**
  216. * Set DateFrom
  217. *
  218. * @param mixed $dateFrom
  219. */
  220. public function setDateFrom( $dateFrom )
  221. {
  222. $this->dateFrom = $dateFrom;
  223. }
  224. /**
  225. * Get DateTo
  226. *
  227. * @return mixed
  228. */
  229. public function getDateTo()
  230. {
  231. return $this->dateTo;
  232. }
  233. /**
  234. * Set DateTo
  235. *
  236. * @param mixed $dateTo
  237. */
  238. public function setDateTo( $dateTo )
  239. {
  240. $this->dateTo = $dateTo;
  241. }
  242. }