AbstractMessage.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Message;
  4. use App\Attribute\OrganizationDefaultValue;
  5. use App\Entity\Organization\Organization;
  6. use App\Enum\Message\MessageStatusEnum;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Ramsey\Uuid\UuidInterface;
  9. use Ramsey\Uuid\Doctrine\UuidGenerator;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Symfony\Bridge\Doctrine\Types\UuidType;
  12. /**
  13. * Classe ... qui ...
  14. */
  15. #[ORM\MappedSuperclass]
  16. #[OrganizationDefaultValue(fieldName: "organization")]
  17. abstract class AbstractMessage
  18. {
  19. #[ORM\Id]
  20. #[ORM\Column]
  21. #[ORM\GeneratedValue]
  22. protected ?int $id = null;
  23. #[ORM\Column(length: 255, nullable: false)]
  24. protected string $discr;
  25. /**
  26. * @var UuidInterface|null
  27. */
  28. #[ORM\Column(type: "uuid", unique: true)]
  29. #[ORM\GeneratedValue(strategy: "CUSTOM")]
  30. #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  31. protected ?UuidInterface $uuid = null;
  32. #[ORM\ManyToOne]
  33. #[ORM\JoinColumn(nullable: true)]
  34. protected Organization $organization;
  35. #[ORM\Column(type: 'string', options: ['default' => 'DRAFT'])]
  36. #[Assert\Choice(callback: [MessageStatusEnum::class, 'toArray'], message: 'invalid-departure-cause')]
  37. protected string $status;
  38. // @todo remplacer par le nom sendingDate
  39. #[ORM\Column(type: 'datetime', nullable: true)]
  40. protected ?\DateTimeInterface $dateSent = null;
  41. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  42. protected string $about;
  43. #[ORM\Column(type: 'text', nullable: true)]
  44. protected string $text;
  45. public function getId(): ?int
  46. {
  47. return $this->id;
  48. }
  49. public function getUuid(): ?UuidInterface
  50. {
  51. return $this->uuid;
  52. }
  53. public function setOrganization(Organization $organization): self
  54. {
  55. $this->organization = $organization;
  56. return $this;
  57. }
  58. public function getOrganization(): Organization
  59. {
  60. return $this->organization;
  61. }
  62. public function setAbout(string $about): self
  63. {
  64. $this->about = $about;
  65. return $this;
  66. }
  67. public function getAbout(): string
  68. {
  69. return $this->about;
  70. }
  71. public function setText(string $text): self
  72. {
  73. $this->text = $text;
  74. return $this;
  75. }
  76. public function getText(): string
  77. {
  78. return html_entity_decode($this->text);
  79. }
  80. public function setStatus(string $status): self
  81. {
  82. $this->status = $status;
  83. return $this;
  84. }
  85. public function getStatus(): string
  86. {
  87. return $this->status;
  88. }
  89. public function setDateSent(\DateTimeInterface $dateSent): self
  90. {
  91. $this->dateSent = $dateSent;
  92. return $this;
  93. }
  94. public function getDateSent(): ?\DateTimeInterface
  95. {
  96. return $this->dateSent;
  97. }
  98. }