src/Entity/Article.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArticleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10. * @ORM\Entity(repositoryClass=ArticleRepository::class)
  11. * @Vich\Uploadable
  12. */
  13. class Article
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. */
  24. private $title;
  25. /**
  26. * @ORM\Column(type="text")
  27. */
  28. private $text;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable= true)
  31. */
  32. private $linkLabel;
  33. /**
  34. * @ORM\Column(type="string", length=255, nullable= true)
  35. */
  36. private $linkUrl;
  37. /**
  38. * @ORM\Column(type="string", length=255, nullable= true)
  39. */
  40. private $altAttribute;
  41. /**
  42. * @ORM\Column(type="date")
  43. */
  44. private $creationDate;
  45. /**
  46. * @ORM\Column(type="date")
  47. */
  48. private $updatedDate;
  49. /**
  50. * @ORM\Column(type="boolean",nullable=true)
  51. */
  52. private $isActive;
  53. /**
  54. * @ORM\Column(type="boolean",nullable=true)
  55. */
  56. private $isUne;
  57. /**
  58. * @ORM\Column(type="string", length=255, nullable=true)
  59. */
  60. private $img;
  61. /**
  62. * @Vich\UploadableField(mapping="frontend_image", fileNameProperty="img")
  63. *
  64. * @var File|null
  65. */
  66. private $imgFile;
  67. /**
  68. * @ORM\Column(type="integer", nullable=true)
  69. */
  70. private $legacyId;
  71. /**
  72. * @ORM\Column(type="boolean", nullable=true)
  73. */
  74. private $isBlog;
  75. /**
  76. * @ORM\Column(type="string", length=255, nullable=true)
  77. */
  78. private $type;
  79. /**
  80. * @ORM\Column(type="string", length=255, nullable=true)
  81. */
  82. private $path;
  83. public function __construct()
  84. {
  85. $this->creationDate = new \Datetime();
  86. $this->updatedDate = new \Datetime();
  87. $this->articleMediaCategories = new ArrayCollection();
  88. }
  89. public function getId(): ?int
  90. {
  91. return $this->id;
  92. }
  93. public function getTitle(): ?string
  94. {
  95. return $this->title;
  96. }
  97. public function setTitle(string $title): self
  98. {
  99. $this->title = $title;
  100. return $this;
  101. }
  102. public function getText(): ?string
  103. {
  104. return $this->text;
  105. }
  106. public function setText(string $text): self
  107. {
  108. $this->text = $text;
  109. return $this;
  110. }
  111. public function getLinkLabel(): ?string
  112. {
  113. return $this->linkLabel;
  114. }
  115. public function setLinkLabel(string $linkLabel): self
  116. {
  117. $this->linkLabel = $linkLabel;
  118. return $this;
  119. }
  120. public function getLinkUrl(): ?string
  121. {
  122. return $this->linkUrl;
  123. }
  124. public function setLinkUrl(string $linkUrl): self
  125. {
  126. $this->linkUrl = $linkUrl;
  127. return $this;
  128. }
  129. public function getAltAttribute(): ?string
  130. {
  131. return $this->linkUrl;
  132. }
  133. public function setAltAttribute(string $linkUrl): self
  134. {
  135. $this->linkUrl = $linkUrl;
  136. return $this;
  137. }
  138. public function getCreationDate(): ?\DateTimeInterface
  139. {
  140. return $this->creationDate;
  141. }
  142. public function setCreationDate(\DateTimeInterface $creationDate): self
  143. {
  144. $this->creationDate = $creationDate;
  145. return $this;
  146. }
  147. public function getUpdatedDate(): ?\DateTimeInterface
  148. {
  149. return $this->updatedDate;
  150. }
  151. public function setUpdatedDate(\DateTimeInterface $updatedDate): self
  152. {
  153. $this->updatedDate = $updatedDate;
  154. return $this;
  155. }
  156. public function getIsUne(): ?bool
  157. {
  158. return $this->isUne;
  159. }
  160. public function SetIsUne(bool $isUne): self
  161. {
  162. $this->isUne = $isUne;
  163. return $this;
  164. }
  165. public function getIsActive(): ?bool
  166. {
  167. return $this->isActive;
  168. }
  169. public function setIsActive(bool $isActive): self
  170. {
  171. $this->isActive = $isActive;
  172. return $this;
  173. }
  174. public function getImg(): ?string
  175. {
  176. return $this->img;
  177. }
  178. public function setImg(?string $img): self
  179. {
  180. $this->img = $img;
  181. if($img !== null){
  182. $this->legacyId = 1;
  183. $this->updatedDate = new \DateTime();
  184. }
  185. return $this;
  186. }
  187. /**
  188. * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  189. * of 'UploadedFile' is injected into this setter to trigger the update. If this
  190. * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  191. * must be able to accept an instance of 'File' as the bundle will inject one here
  192. * during Doctrine hydration.
  193. *
  194. * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  195. */
  196. public function setImgFile(?File $imageFile = null)
  197. {
  198. $this->imgFile = $imageFile;
  199. if ($imageFile) {
  200. $this->legacyId = 1;
  201. $this->updatedDate = new \DateTime();
  202. }
  203. return true;
  204. }
  205. public function getImgFile(): ?File
  206. {
  207. return $this->imgFile;
  208. }
  209. public function getLegacyId(): ?int
  210. {
  211. return $this->legacyId;
  212. }
  213. public function setLegacyId(?int $legacyId): self
  214. {
  215. $this->legacyId = $legacyId;
  216. return $this;
  217. }
  218. public function getIsBlog(): ?bool
  219. {
  220. return $this->isBlog;
  221. }
  222. public function setIsBlog(?bool $isBlog): self
  223. {
  224. $this->isBlog = $isBlog;
  225. return $this;
  226. }
  227. public function getType(): ?string
  228. {
  229. return $this->type;
  230. }
  231. public function setType(?string $type): self
  232. {
  233. $this->type = $type;
  234. return $this;
  235. }
  236. public function getPath(): ?string
  237. {
  238. return $this->path;
  239. }
  240. public function setPath(?string $path): self
  241. {
  242. $this->path = $path;
  243. return $this;
  244. }
  245. }