OrganizationFunction.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Access;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Annotation\DateTimeConstraintAware;
  6. use App\Entity\Traits\ActivityPeriodTrait;
  7. use App\Repository\Access\OrganizationFunctionRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11. * Fonction d'un Access dans une Organization sur une période donnée
  12. */
  13. #[ApiResource]
  14. #[ORM\Entity(repositoryClass: OrganizationFunctionRepository::class)]
  15. #[DateTimeConstraintAware(startDateFieldName: "startDate", endDateFieldName: "endDate")]
  16. class OrganizationFunction
  17. {
  18. use ActivityPeriodTrait;
  19. #[ORM\Id]
  20. #[ORM\GeneratedValue]
  21. #[ORM\Column]
  22. private ?int $id = null;
  23. #[ORM\ManyToOne(inversedBy: 'organizationFunction')]
  24. private ?Access $access = null;
  25. #[ORM\ManyToOne]
  26. #[ORM\JoinColumn(nullable: false)]
  27. private FunctionType $functionType;
  28. #[ORM\Column(length: 255, nullable: true)]
  29. private ?string $functionComplement = null;
  30. #[ORM\Column(length: 255, nullable: true)]
  31. #[Assert\Choice(callback: ['\App\Enum\Access\DeparturesCauseEnum', 'toArray'], message: 'invalid-departure-cause')]
  32. private ?string $departureCause = null;
  33. #[ORM\Column(options: ['default' => true])]
  34. private bool $isMemberSection = true;
  35. public function getId(): ?int
  36. {
  37. return $this->id;
  38. }
  39. public function getAccess(): ?Access
  40. {
  41. return $this->access;
  42. }
  43. public function setAccess(?Access $access): self
  44. {
  45. $this->access = $access;
  46. return $this;
  47. }
  48. public function setFunctionType(FunctionType $functionType): self
  49. {
  50. $this->functionType = $functionType;
  51. return $this;
  52. }
  53. public function getFunctionType(): FunctionType
  54. {
  55. return $this->functionType;
  56. }
  57. public function getFunctionComplement(): ?string
  58. {
  59. return $this->functionComplement;
  60. }
  61. public function setFunctionComplement(?string $functionComplement): self
  62. {
  63. $this->functionComplement = $functionComplement;
  64. return $this;
  65. }
  66. public function setDepartureCause(?string $departureCause): self
  67. {
  68. $this->departureCause = $departureCause;
  69. return $this;
  70. }
  71. public function getDepartureCause():?string
  72. {
  73. return $this->departureCause;
  74. }
  75. public function setIsMemberSection(bool $isMemberSection): self
  76. {
  77. $this->isMemberSection = $isMemberSection;
  78. return $this;
  79. }
  80. public function getIsMemberSection(): bool
  81. {
  82. return $this->isMemberSection;
  83. }
  84. }