NetworkOrganization.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Network;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use App\Attribute\DateTimeConstraintAware;
  8. use App\Entity\Organization\Organization;
  9. use App\Repository\Network\NetworkOrganizationRepository;
  10. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14. * Fait le lien entre une Organization et un Network
  15. *
  16. * Security :
  17. * * @see App\Doctrine\Network\CurrentNetworkOrganizationExtension
  18. */
  19. #[ApiResource(operations: [])]
  20. //#[Auditable]
  21. #[ORM\Entity(repositoryClass: NetworkOrganizationRepository::class)]
  22. #[DateTimeConstraintAware(startDateFieldName: "startDate", endDateFieldName: "endDate")]
  23. class NetworkOrganization
  24. {
  25. #[ORM\Id]
  26. #[ORM\Column]
  27. #[ORM\GeneratedValue]
  28. #[Groups("network")]
  29. private ?int $id = null;
  30. #[ORM\ManyToOne(inversedBy: 'organizations')]
  31. #[ORM\JoinColumn(nullable: true)]
  32. #[Groups("network")]
  33. private Network $network;
  34. #[ORM\ManyToOne(inversedBy: 'networkOrganizations')]
  35. #[ORM\JoinColumn(nullable: true)]
  36. private Organization $organization;
  37. #[ORM\ManyToOne(inversedBy: 'networkOrganizationChildren')]
  38. private ?Organization $parent;
  39. #[ORM\Column(length: 255, nullable: true)]
  40. private ?string $leadingCause = null;
  41. #[ORM\Column(type: 'date', nullable: true)]
  42. #[Groups("network")]
  43. private ?\DateTimeInterface $startDate = null;
  44. #[ORM\Column(type: 'date', nullable: true)]
  45. private ?\DateTimeInterface $endDate = null;
  46. public function getId(): ?int
  47. {
  48. return $this->id;
  49. }
  50. public function getNetwork(): ?Network
  51. {
  52. return $this->network;
  53. }
  54. public function setNetwork(?Network $network): self
  55. {
  56. $this->network = $network;
  57. return $this;
  58. }
  59. public function getOrganization(): ?Organization
  60. {
  61. return $this->organization;
  62. }
  63. public function setOrganization(?Organization $organization): self
  64. {
  65. $this->organization = $organization;
  66. return $this;
  67. }
  68. public function getParent(): ?Organization
  69. {
  70. return $this->parent;
  71. }
  72. public function setParent(?Organization $parent): self
  73. {
  74. $this->parent = $parent;
  75. return $this;
  76. }
  77. public function getLeadingCause(): ?string
  78. {
  79. return $this->leadingCause;
  80. }
  81. public function setLeadingCause(?string $leadingCause): self
  82. {
  83. $this->leadingCause = $leadingCause;
  84. return $this;
  85. }
  86. public function getStartDate(): ?\DateTimeInterface
  87. {
  88. return $this->startDate;
  89. }
  90. public function setStartDate(?\DateTime $startDate = null): self
  91. {
  92. if ($startDate == null) {
  93. $startDate = new \DateTime();
  94. }
  95. $this->startDate = $startDate;
  96. return $this;
  97. }
  98. public function getEndDate(): ?\DateTimeInterface
  99. {
  100. return $this->endDate;
  101. }
  102. public function setEndDate(?\DateTime $endDate = null): self
  103. {
  104. $this->endDate = $endDate;
  105. return $this;
  106. }
  107. }