DocumentWish.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\AccessWish;
  4. use App\Entity\Core\File;
  5. use App\Entity\Person\Person;
  6. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Doctrine\Common\Collections\Collection;
  10. /**
  11. * Classe ... qui ...
  12. */
  13. //#[Auditable]
  14. #[ORM\Entity]
  15. class DocumentWish
  16. {
  17. #[ORM\Id]
  18. #[ORM\Column]
  19. #[ORM\GeneratedValue]
  20. private ?int $id = null;
  21. #[ORM\ManyToOne(inversedBy: 'documentWishes')]
  22. #[ORM\JoinColumn(referencedColumnName: 'id' ,nullable: true, onDelete: 'SET NULL')]
  23. private AccessWish $accessWish;
  24. #[ORM\ManyToOne(inversedBy: 'documentWishes')]
  25. #[ORM\JoinColumn(referencedColumnName: 'id' ,nullable: true, onDelete: 'SET NULL')]
  26. private Person $personOwner;
  27. #[ORM\OneToMany(mappedBy: 'documentWish', targetEntity: File::class, orphanRemoval: true)]
  28. private Collection $files;
  29. public function __construct()
  30. {
  31. $this->files = new ArrayCollection();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getAccessWish(): ?AccessWish
  38. {
  39. return $this->accessWish;
  40. }
  41. public function setAccessWish(?AccessWish $accessWish): self
  42. {
  43. $this->accessWish = $accessWish;
  44. return $this;
  45. }
  46. public function getPersonOwner(): ?Person
  47. {
  48. return $this->personOwner;
  49. }
  50. public function setPersonOwner(?Person $personOwner): self
  51. {
  52. $this->personOwner = $personOwner;
  53. return $this;
  54. }
  55. /**
  56. * @return Collection<int, File>
  57. */
  58. public function getFiles(): Collection
  59. {
  60. return $this->files;
  61. }
  62. public function addFile(File $file): self
  63. {
  64. if (!$this->files->contains($file)) {
  65. $this->files[] = $file;
  66. $file->setDocumentWish($this);
  67. }
  68. return $this;
  69. }
  70. public function removeFile(File $file): self
  71. {
  72. if ($this->files->removeElement($file)) {
  73. // set the owning side to null (unless already changed)
  74. if ($file->getDocumentWish() === $this) {
  75. $file->setDocumentWish(null);
  76. }
  77. }
  78. return $this;
  79. }
  80. }