NetworkOrganization.php 3.2 KB

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