File.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Core;
  4. use App\Entity\Organization\Organization;
  5. use App\Entity\Person\Person;
  6. use App\Repository\Core\FileRepository;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use JetBrains\PhpStorm\Pure;
  12. #[ORM\Entity(repositoryClass: FileRepository::class)]
  13. class File
  14. {
  15. #[ORM\Id]
  16. #[ORM\Column]
  17. #[ORM\GeneratedValue]
  18. private ?int $id = null;
  19. /**
  20. * Propriétaire du fichier
  21. *
  22. * @var Person
  23. */
  24. #[ORM\ManyToOne]
  25. private Person $person;
  26. /**
  27. * Organisation propriétaire du fichier
  28. * @var Organization
  29. */
  30. #[ORM\ManyToOne]
  31. private Organization $organization;
  32. /**
  33. * Slug du fichier (i.e. le chemin d'accès relatif)
  34. * @var string
  35. */
  36. #[ORM\Column(length: 255)]
  37. private string $slug;
  38. /**
  39. * Chemin d'accès du fichier
  40. * @var string
  41. */
  42. #[ORM\Column(length: 255)]
  43. private string $path;
  44. /**
  45. * Nom du fichier
  46. * @var string
  47. */
  48. #[ORM\Column(length: 255)]
  49. private string $name;
  50. /**
  51. * Mimetype du fichier
  52. * @var string|null
  53. */
  54. #[ORM\Column(length: 255, nullable: true)]
  55. private ?string $mimeType = null;
  56. /**
  57. * Visibilité du fichier (tout le monde, personne, l'organisation seulement...)
  58. * @var string
  59. */
  60. #[ORM\Column(length: 24, options: ['default' => 'NOBODY'])]
  61. private string $visibility = 'NOBODY';
  62. /**
  63. * Configuration particulière associée au fichier (exemple: image recadrée)
  64. * @var string|null
  65. */
  66. #[ORM\Column(type: 'text', nullable: true)]
  67. private ?string $config;
  68. /**
  69. * Dossier contenant le fichier
  70. * @var string
  71. */
  72. #[ORM\Column(length: 24)]
  73. private string $folder;
  74. /**
  75. * Type de document (uploaded, mail, bill...etc)
  76. * @var string
  77. */
  78. #[ORM\Column(length: 50, options: ['default' => 'NONE'])]
  79. private string $type = "NONE";
  80. /**
  81. * Taille du document en octets
  82. * @var int|null
  83. */
  84. #[ORM\Column]
  85. private ?int $size;
  86. /**
  87. * Un fichier est temporaire par exemple s'il a été généré et est stocké pour être téléchargé dans la foulée
  88. * Les fichiers temporaires peuvent être supprimés sans risque, à l'inverse des fichiers uploadés par les
  89. * utilisateurs par exemple.
  90. *
  91. * @var boolean
  92. */
  93. #[ORM\Column(options: ['default' => false])]
  94. private bool $isTemporaryFile = false;
  95. /**
  96. * Date de création du fichier
  97. * @var DateTime
  98. */
  99. #[ORM\Column]
  100. private DateTime $createDate;
  101. /**
  102. * Id de l'access ayant créé ce fichier
  103. * @var int|null
  104. */
  105. #[ORM\Column]
  106. private ?int $createdBy;
  107. /**
  108. * Date de dernière mise à jour du fichier
  109. * @var DateTime
  110. */
  111. #[ORM\Column]
  112. private DateTime $updateDate;
  113. /**
  114. * Id de l'access ayant mis à jour ce fichier le dernier
  115. * @var int|null
  116. */
  117. #[ORM\Column]
  118. private ?int $updatedBy;
  119. // #[ORM\Column]
  120. // private ?int $eventReport_id;
  121. //
  122. // #[ORM\Column]
  123. // private ?\DateTime $availabilityDate;
  124. //
  125. // #[ORM\Column]
  126. // private ?int $documentWish_id;
  127. //
  128. // #[ORM\Column]
  129. // private ?int $onlineRegistrationSetting_id;
  130. //
  131. // #[ORM\Column]
  132. // private ?int $templateSystem_id;
  133. //
  134. // #[ORM\Column]
  135. // private ?int $work_id;
  136. #[ORM\OneToMany(mappedBy: 'image', targetEntity: Person::class, orphanRemoval: true)]
  137. private Collection $personImages;
  138. #[Pure] public function __construct()
  139. {
  140. $this->personImages = new ArrayCollection();
  141. }
  142. public function getId(): ?int
  143. {
  144. return $this->id;
  145. }
  146. /**
  147. * @return Person
  148. */
  149. public function getPerson(): Person
  150. {
  151. return $this->person;
  152. }
  153. /**
  154. * @param Person $person
  155. */
  156. public function setPerson(Person $person): void
  157. {
  158. $this->person = $person;
  159. }
  160. /**
  161. * @return Organization
  162. */
  163. public function getOrganization(): Organization
  164. {
  165. return $this->organization;
  166. }
  167. /**
  168. * @param Organization $organization
  169. */
  170. public function setOrganization(Organization $organization): void
  171. {
  172. $this->organization = $organization;
  173. }
  174. public function getSlug(): string
  175. {
  176. return $this->slug;
  177. }
  178. public function setSlug(string $slug): self
  179. {
  180. $this->slug = $slug;
  181. return $this;
  182. }
  183. public function getPath(): string
  184. {
  185. return $this->path;
  186. }
  187. public function setPath(string $path): self
  188. {
  189. $this->path = $path;
  190. return $this;
  191. }
  192. public function getName(): string
  193. {
  194. return $this->name;
  195. }
  196. public function setName(string $name): self
  197. {
  198. $this->name = $name;
  199. return $this;
  200. }
  201. public function getMimeType(): ?string
  202. {
  203. return $this->mimeType;
  204. }
  205. public function setMimeType(?string $mimeType): self
  206. {
  207. $this->mimeType = $mimeType;
  208. return $this;
  209. }
  210. public function getPersonImages(): Collection
  211. {
  212. return $this->personImages;
  213. }
  214. public function addPersonImage (Person $person): self
  215. {
  216. if (!$this->personImages->contains($person)) {
  217. $this->personImages[] = $person;
  218. $person->setImage($this);
  219. }
  220. return $this;
  221. }
  222. public function removePersonImage(Person $person): self
  223. {
  224. if ($this->personImages->removeElement($person)) {
  225. // set the owning side to null (unless already changed)
  226. if ($person->getImage() === $this) {
  227. $person->setImage(null);
  228. }
  229. }
  230. return $this;
  231. }
  232. /**
  233. * @return string
  234. */
  235. public function getVisibility(): string
  236. {
  237. return $this->visibility;
  238. }
  239. /**
  240. * @param string $visibility
  241. */
  242. public function setVisibility(string $visibility): void
  243. {
  244. $this->visibility = $visibility;
  245. }
  246. /**
  247. * @return string|null
  248. */
  249. public function getConfig(): ?string
  250. {
  251. return $this->config;
  252. }
  253. /**
  254. * @param string|null $config
  255. */
  256. public function setConfig(?string $config): void
  257. {
  258. $this->config = $config;
  259. }
  260. /**
  261. * @return string
  262. */
  263. public function getFolder(): string
  264. {
  265. return $this->folder;
  266. }
  267. /**
  268. * @param string $folder
  269. */
  270. public function setFolder(string $folder): void
  271. {
  272. $this->folder = $folder;
  273. }
  274. /**
  275. * @return string
  276. */
  277. public function getType(): string
  278. {
  279. return $this->type;
  280. }
  281. /**
  282. * @param string $type
  283. */
  284. public function setType(string $type): void
  285. {
  286. $this->type = $type;
  287. }
  288. /**
  289. * @return int|null
  290. */
  291. public function getSize(): ?int
  292. {
  293. return $this->size;
  294. }
  295. /**
  296. * @param int|null $size
  297. */
  298. public function setSize(?int $size): void
  299. {
  300. $this->size = $size;
  301. }
  302. /**
  303. * @return bool
  304. */
  305. public function getIsTemporaryFile(): bool
  306. {
  307. return $this->isTemporaryFile;
  308. }
  309. /**
  310. * @param bool $isTemporaryFile
  311. */
  312. public function setIsTemporaryFile(bool $isTemporaryFile): void
  313. {
  314. $this->isTemporaryFile = $isTemporaryFile;
  315. }
  316. /**
  317. * @return DateTime
  318. */
  319. public function getCreateDate(): DateTime
  320. {
  321. return $this->createDate;
  322. }
  323. /**
  324. * @param DateTime $createDate
  325. */
  326. public function setCreateDate(DateTime $createDate): void
  327. {
  328. $this->createDate = $createDate;
  329. }
  330. /**
  331. * @return int|null
  332. */
  333. public function getCreatedBy(): ?int
  334. {
  335. return $this->createdBy;
  336. }
  337. /**
  338. * @param int|null $createdBy
  339. */
  340. public function setCreatedBy(?int $createdBy): void
  341. {
  342. $this->createdBy = $createdBy;
  343. }
  344. /**
  345. * @return DateTime
  346. */
  347. public function getUpdateDate(): DateTime
  348. {
  349. return $this->updateDate;
  350. }
  351. /**
  352. * @param DateTime $updateDate
  353. */
  354. public function setUpdateDate(DateTime $updateDate): void
  355. {
  356. $this->updateDate = $updateDate;
  357. }
  358. /**
  359. * @return int|null
  360. */
  361. public function getUpdatedBy(): ?int
  362. {
  363. return $this->updatedBy;
  364. }
  365. /**
  366. * @param int|null $updatedBy
  367. */
  368. public function setUpdatedBy(?int $updatedBy): void
  369. {
  370. $this->updatedBy = $updatedBy;
  371. }
  372. }