src/Entity/Parameter.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ParameterRepository;
  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=ParameterRepository::class)
  14. * @ORM\HasLifecycleCallbacks()
  15. *
  16. * @Serializer\ExclusionPolicy("ALL")
  17. *
  18. * @Vich\Uploadable
  19. */
  20. class Parameter
  21. {
  22. /**
  23. * @ORM\Id
  24. * @ORM\GeneratedValue
  25. * @ORM\Column(type="integer")
  26. *
  27. * @Expose
  28. * @Groups({"parameter"})
  29. */
  30. private ?int $id = NULL;
  31. /**
  32. * @ORM\Column(type="string")
  33. *
  34. * @Expose
  35. * @Groups({"parameter"})
  36. */
  37. private string $slug = '';
  38. /**
  39. * @ORM\Column(type="text", nullable=true)
  40. */
  41. private ?string $value = null;
  42. /**
  43. * @ORM\Column(type="string", length=255, nullable=true)
  44. *
  45. * @Expose
  46. * @Groups({"parameter"})
  47. */
  48. private ?string $title = null;
  49. /**
  50. * @ORM\Column(type="string", length=255, nullable=true)
  51. *
  52. * @Expose
  53. * @Groups({"parameter"})
  54. */
  55. private ?string $fileName = null;
  56. /**
  57. * @Vich\UploadableField(mapping="general_documents", fileNameProperty="fileName")
  58. */
  59. private ?File $file = null;
  60. /**
  61. * @ORM\Column(type="string", length=255, nullable=true)
  62. */
  63. private ?string $originalName = null;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. *
  67. * @Expose
  68. * @Groups({"parameter"})
  69. */
  70. private ?string $externLink = null;
  71. /**
  72. * @deprecated
  73. * @ORM\Column(type="boolean", nullable=true)
  74. */
  75. private ?bool $noFooter = null;
  76. /**
  77. * @ORM\Column(type="string", length=255, nullable=true)
  78. */
  79. private ?string $displayRole = null;
  80. /**
  81. * @ORM\Column(type="string", length=255, nullable=true)
  82. */
  83. private ?string $displayJob = null;
  84. /**
  85. * @ORM\ManyToOne(targetEntity=ParameterHook::class, inversedBy="parameters")
  86. *
  87. * @Expose
  88. * @Groups({"parameter"})
  89. */
  90. private ?ParameterHook $parameterHook = null;
  91. /**
  92. * @ORM\Column(type="string", length=255, nullable=true)
  93. */
  94. private $thumbnail;
  95. // Vich Uploader
  96. /**
  97. * @Vich\UploadableField(mapping="parameter_thumbnail", fileNameProperty="thumbnail")
  98. * @var File
  99. */
  100. private $thumbnailFile;
  101. /**
  102. * @ORM\Column(type="string", length=255, nullable=true)
  103. */
  104. private $displayUniverses;
  105. /**
  106. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="relatedParameters")
  107. *
  108. * @Expose
  109. * @Groups({"parameter"})
  110. */
  111. private $userRelated;
  112. /**
  113. * @ORM\Column(type="boolean", nullable=true)
  114. * @Expose
  115. * @Groups({"parameter"})
  116. */
  117. private $public;
  118. /**
  119. * @ORM\Column(type="string", length=16, nullable=true)
  120. */
  121. private $display;
  122. /**
  123. * @ORM\Column(type="string", length=255, nullable=true)
  124. * @Expose
  125. * @Groups({"parameter"})
  126. */
  127. private ?string $language = null;
  128. /**
  129. * @ORM\Column(type="string", length=255, nullable=true)
  130. */
  131. private ?string $newsOavSlug = null;
  132. use DateTrait;
  133. public function getFile(): ?File
  134. {
  135. return $this->file ?? NULL;
  136. }
  137. public function setFile(File $file = NULL): void
  138. {
  139. $this->file = $file;
  140. if($file)
  141. {
  142. $this->updatedAt = new DateTime('now');
  143. }
  144. }
  145. public function getId(): ?int
  146. {
  147. return $this->id;
  148. }
  149. public function getSlug(): ?string
  150. {
  151. return $this->slug ?? NULL;
  152. }
  153. public function setSlug(string $slug): self
  154. {
  155. $this->slug = $slug;
  156. return $this;
  157. }
  158. public function getValue(): ?string
  159. {
  160. return $this->value ?? NULL;
  161. }
  162. public function setValue(?string $value): self
  163. {
  164. $this->value = $value;
  165. return $this;
  166. }
  167. public function getTitle(): ?string
  168. {
  169. return $this->title ?? NULL;
  170. }
  171. public function setTitle(?string $title): self
  172. {
  173. $this->title = $title;
  174. return $this;
  175. }
  176. public function getFileName(): ?string
  177. {
  178. return $this->fileName ?? NULL;
  179. }
  180. public function setFileName(?string $fileName): self
  181. {
  182. $this->fileName = $fileName;
  183. return $this;
  184. }
  185. public function getOriginalName(): ?string
  186. {
  187. return $this->originalName ?? NULL;
  188. }
  189. public function setOriginalName(?string $originalName): self
  190. {
  191. $this->originalName = $originalName;
  192. return $this;
  193. }
  194. public function getExternLink(): ?string
  195. {
  196. return $this->externLink ?? NULL;
  197. }
  198. public function setExternLink(?string $externLink): self
  199. {
  200. $this->externLink = $externLink;
  201. return $this;
  202. }
  203. public function getNoFooter(): ?bool
  204. {
  205. return $this->noFooter;
  206. }
  207. public function setNoFooter(?bool $noFooter): self
  208. {
  209. $this->noFooter = $noFooter;
  210. return $this;
  211. }
  212. public function getDisplayRole(): ?array
  213. {
  214. if($this->displayRole === NULL)
  215. {
  216. return NULL;
  217. }
  218. return explode(';', $this->displayRole);
  219. }
  220. public function setDisplayRole(?array $displayRole): self
  221. {
  222. if($displayRole === [])
  223. {
  224. $this->displayRole = NULL;
  225. }
  226. else
  227. {
  228. $this->displayRole = implode(';', $displayRole);
  229. }
  230. return $this;
  231. }
  232. public function getDisplayJob(): ?array
  233. {
  234. if($this->displayJob === NULL)
  235. {
  236. return NULL;
  237. }
  238. return explode(';', $this->displayJob);
  239. }
  240. public function setDisplayJob(?array $displayJob): self
  241. {
  242. if($displayJob === [])
  243. {
  244. $this->displayJob = NULL;
  245. }
  246. else
  247. {
  248. $this->displayJob = implode(';', $displayJob);
  249. }
  250. return $this;
  251. }
  252. public function getParameterHook(): ?ParameterHook
  253. {
  254. return $this->parameterHook;
  255. }
  256. public function setParameterHook(?ParameterHook $parameterHook): self
  257. {
  258. $this->parameterHook = $parameterHook;
  259. return $this;
  260. }
  261. public function getThumbnail(): ?string
  262. {
  263. return $this->thumbnail;
  264. }
  265. public function setThumbnail(?string $thumbnail): self
  266. {
  267. $this->thumbnail = $thumbnail;
  268. return $this;
  269. }
  270. public function getThumbnailFile(): ?File
  271. {
  272. return $this->thumbnailFile;
  273. }
  274. /**
  275. * @param File $thumbnailFile
  276. *
  277. * @return void
  278. */
  279. public function setThumbnailFile(File $thumbnailFile): void
  280. {
  281. $this->thumbnailFile = $thumbnailFile;
  282. if(NULL !== $thumbnailFile)
  283. {
  284. // It is required that at least one field changes if you are using doctrine
  285. // otherwise the event listeners won't be called and the file is lost
  286. $this->updatedAt = new DateTime();
  287. }
  288. }
  289. public function getDisplayUniverses(): ?array
  290. {
  291. if($this->displayUniverses === NULL)
  292. {
  293. return NULL;
  294. }
  295. return explode(';', $this->displayUniverses);
  296. }
  297. public function setDisplayUniverses(?array $displayUniverses): self
  298. {
  299. if($displayUniverses === [])
  300. {
  301. $this->displayUniverses = NULL;
  302. }
  303. else
  304. {
  305. $this->displayUniverses = implode(';', $displayUniverses);
  306. }
  307. return $this;
  308. }
  309. public function getUserRelated(): ?User
  310. {
  311. return $this->userRelated;
  312. }
  313. public function setUserRelated(?User $userRelated): self
  314. {
  315. $this->userRelated = $userRelated;
  316. return $this;
  317. }
  318. public function isPublic(): ?bool
  319. {
  320. return $this->public ?? FALSE;
  321. }
  322. public function setPublic(?bool $public): self
  323. {
  324. $this->public = $public;
  325. return $this;
  326. }
  327. public function getDisplay(): ?string
  328. {
  329. return $this->display;
  330. }
  331. public function setDisplay(?string $display): self
  332. {
  333. $this->display = $display;
  334. return $this;
  335. }
  336. public function getLanguage(): ?string
  337. {
  338. return $this->language ?? NULL;
  339. }
  340. public function setLanguage(string $language): self
  341. {
  342. $this->language = $language;
  343. return $this;
  344. }
  345. public function setNewsOavSlug(?string $newsOavSlug): self
  346. {
  347. $this->newsOavSlug = $newsOavSlug;
  348. return $this;
  349. }
  350. public function getNewsOavSlug(): ?string
  351. {
  352. return $this->newsOavSlug;
  353. }
  354. }