src/Entity/Advertising.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AdvertisingRepository;
  4. use App\Traits\DateTrait;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13. * @ORM\Entity(repositoryClass=AdvertisingRepository::class)
  14. *
  15. * @Serializer\ExclusionPolicy("ALL")
  16. * @Vich\Uploadable
  17. */
  18. class Advertising
  19. {
  20. /**
  21. * @ORM\Id
  22. * @ORM\GeneratedValue
  23. * @ORM\Column(type="integer")
  24. *
  25. * @Expose
  26. * @Groups({"advertising"})
  27. */
  28. private $id;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable=true)
  31. *
  32. * @Expose
  33. * @Groups({"advertising"})
  34. */
  35. private $path;
  36. // Vich Uploader
  37. /**
  38. * @Vich\UploadableField(mapping="advertising_images", fileNameProperty="path")
  39. * @var File
  40. */
  41. private $imageFile;
  42. // /**
  43. // * @Assert\File(maxSize="6000000")
  44. // */
  45. // private $file;
  46. // /**
  47. // * @ORM\Column(type="datetime", nullable=true)
  48. // */
  49. // private $uploadDate;
  50. /**
  51. * @ORM\Column(type="string", length=512, nullable=true)
  52. *
  53. * @Expose
  54. * @Groups({"advertising"})
  55. */
  56. private $targetURI;
  57. /**
  58. * @ORM\Column(type="boolean", options={"default":false})
  59. *
  60. * @Expose
  61. * @Groups({"advertising"})
  62. */
  63. private $inNewTab = FALSE;
  64. /**
  65. * @ORM\Column(type="boolean", options={"default":false})
  66. *
  67. * @Expose
  68. * @Groups({"advertising"})
  69. */
  70. private $isDefault;
  71. /**
  72. * @ORM\Column(type="string", length=10, nullable=true)
  73. *
  74. * @Expose
  75. * @Groups({"advertising"})
  76. */
  77. private $locale;
  78. /**
  79. * @ORM\Column(type="text", nullable=true)
  80. *
  81. * @Expose
  82. * @Groups({"advertising"})
  83. */
  84. private $caption;
  85. // private $rootdir;
  86. use DateTrait;
  87. public function __construct()
  88. {
  89. // if (!file_exists($this->getUploadRootDir())) {
  90. // mkdir($this->getUploadRootDir(), 0777, TRUE);
  91. // }
  92. $this->isDefault = FALSE;
  93. }
  94. /*
  95. * ============================================================================================
  96. * =============================== FONCTIONS CUSTOM ===========================================
  97. * ============================================================================================
  98. */
  99. public function getImageFile(): File
  100. {
  101. return $this->imageFile;
  102. }
  103. public function setImageFile(File $imageFile): Advertising
  104. {
  105. $this->imageFile = $imageFile;
  106. if (NULL !== $imageFile) {
  107. // It is required that at least one field changes if you are using doctrine
  108. // otherwise the event listeners won't be called and the file is lost
  109. $this->updatedAt = new DateTime();
  110. }
  111. return $this;
  112. }
  113. public function getId(): ?int
  114. {
  115. return $this->id;
  116. }
  117. public function getPath(): ?string
  118. {
  119. return $this->path;
  120. }
  121. public function setPath(?string $path): self
  122. {
  123. $this->path = $path;
  124. return $this;
  125. }
  126. public function getTargetURI(): ?string
  127. {
  128. return $this->targetURI;
  129. }
  130. public function setTargetURI(?string $targetURI): self
  131. {
  132. $this->targetURI = $targetURI;
  133. return $this;
  134. }
  135. public function getInNewTab(): ?bool
  136. {
  137. return $this->inNewTab;
  138. }
  139. public function setInNewTab(bool $inNewTab): self
  140. {
  141. $this->inNewTab = $inNewTab;
  142. return $this;
  143. }
  144. public function getIsDefault(): ?bool
  145. {
  146. return $this->isDefault;
  147. }
  148. public function setIsDefault(bool $isDefault): self
  149. {
  150. $this->isDefault = $isDefault;
  151. return $this;
  152. }
  153. public function getLocale(): ?string
  154. {
  155. return $this->locale;
  156. }
  157. public function setLocale(?string $locale): self
  158. {
  159. $this->locale = $locale;
  160. return $this;
  161. }
  162. public function getCaption(): ?string
  163. {
  164. return $this->caption;
  165. }
  166. public function setCaption(?string $caption): self
  167. {
  168. $this->caption = $caption;
  169. return $this;
  170. }
  171. }