DocumentWish.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\AccessWish;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\File;
  6. use App\Entity\Person\Person;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use App\Entity\Person\PersonActivity;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13. * TODO: documenter
  14. */
  15. // #[Auditable]
  16. #[ApiResource(operations: [])]
  17. #[ORM\Entity]
  18. class DocumentWish
  19. {
  20. #[ORM\Id]
  21. #[ORM\Column]
  22. #[ORM\GeneratedValue]
  23. private ?int $id = null;
  24. #[ORM\ManyToOne(inversedBy: 'documentWishes')]
  25. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  26. private ?AccessWish $accessWish = null;
  27. #[ORM\ManyToOne(inversedBy: 'documentWishes')]
  28. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  29. private ?Person $personOwner = null;
  30. /** @var Collection<int, File> */
  31. #[ORM\OneToMany(targetEntity: File::class, mappedBy: 'documentWish', orphanRemoval: true)]
  32. private Collection $files;
  33. #[ORM\OneToOne(inversedBy: 'documentRib', targetEntity: AccessWish::class, cascade: [])]
  34. protected AccessWish $accessWishRib;
  35. #[ORM\OneToOne(inversedBy: 'documentSepa', targetEntity: AccessWish::class, cascade: [])]
  36. protected AccessWish $accessWishSepa;
  37. public function __construct()
  38. {
  39. $this->files = new ArrayCollection();
  40. }
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. public function getAccessWish(): ?AccessWish
  46. {
  47. return $this->accessWish;
  48. }
  49. public function setAccessWish(?AccessWish $accessWish): self
  50. {
  51. $this->accessWish = $accessWish;
  52. return $this;
  53. }
  54. public function getPersonOwner(): ?Person
  55. {
  56. return $this->personOwner;
  57. }
  58. public function setPersonOwner(?Person $personOwner): self
  59. {
  60. $this->personOwner = $personOwner;
  61. return $this;
  62. }
  63. /**
  64. * @return Collection<int, File>
  65. */
  66. public function getFiles(): Collection
  67. {
  68. return $this->files;
  69. }
  70. public function addFile(File $file): self
  71. {
  72. if (!$this->files->contains($file)) {
  73. $this->files[] = $file;
  74. $file->setDocumentWish($this);
  75. }
  76. return $this;
  77. }
  78. public function removeFile(File $file): self
  79. {
  80. if ($this->files->removeElement($file)) {
  81. // set the owning side to null (unless already changed)
  82. if ($file->getDocumentWish() === $this) {
  83. $file->setDocumentWish(null);
  84. }
  85. }
  86. return $this;
  87. }
  88. public function getAccessWishRib(): AccessWish
  89. {
  90. return $this->accessWishRib;
  91. }
  92. public function setAccessWishRib(AccessWish $accessWishRib): self
  93. {
  94. $this->accessWishRib = $accessWishRib;
  95. return $this;
  96. }
  97. public function getAccessWishSepa(): AccessWish
  98. {
  99. return $this->accessWishSepa;
  100. }
  101. public function setAccessWishSepa(AccessWish $accessWishSepa): self
  102. {
  103. $this->accessWishSepa = $accessWishSepa;
  104. return $this;
  105. }
  106. }