AbstractMessage.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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\Doctrine\UuidGenerator;
  9. use Ramsey\Uuid\UuidInterface;
  10. /**
  11. * Classe ... qui ...
  12. */
  13. #[ORM\MappedSuperclass]
  14. #[OrganizationDefaultValue(fieldName: 'organization')]
  15. abstract class AbstractMessage
  16. {
  17. /**
  18. * IMPORTANT! Cette propriété doit être déclarée avant l'id, pour prévenir un bug doctrine.
  19. *
  20. * @see https://github.com/doctrine/orm/issues/7215
  21. */
  22. #[ORM\Column(type: 'uuid', unique: true)]
  23. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  24. #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  25. protected ?UuidInterface $uuid = null;
  26. #[ORM\Id]
  27. #[ORM\Column]
  28. #[ORM\GeneratedValue]
  29. protected ?int $id = null;
  30. #[ORM\Column(length: 255, nullable: false)]
  31. protected string $discr;
  32. #[ORM\ManyToOne]
  33. #[ORM\JoinColumn(nullable: true)]
  34. protected Organization $organization;
  35. #[ORM\Column(length: 50, enumType: MessageStatusEnum::class, options: ['default' => 'DRAFT'])]
  36. protected MessageStatusEnum $status = MessageStatusEnum::DRAFT;
  37. // @todo remplacer par le nom sendingDate
  38. #[ORM\Column(type: 'datetime', nullable: true)]
  39. protected ?\DateTimeInterface $dateSent = null;
  40. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  41. protected string $about;
  42. #[ORM\Column(type: 'text', nullable: true)]
  43. protected string $text;
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getUuid(): ?UuidInterface
  49. {
  50. return $this->uuid;
  51. }
  52. public function setOrganization(Organization $organization): self
  53. {
  54. $this->organization = $organization;
  55. return $this;
  56. }
  57. public function getOrganization(): Organization
  58. {
  59. return $this->organization;
  60. }
  61. public function setAbout(string $about): self
  62. {
  63. $this->about = $about;
  64. return $this;
  65. }
  66. public function getAbout(): string
  67. {
  68. return $this->about;
  69. }
  70. public function setText(string $text): self
  71. {
  72. $this->text = $text;
  73. return $this;
  74. }
  75. public function getText(): string
  76. {
  77. return html_entity_decode($this->text);
  78. }
  79. public function setStatus(MessageStatusEnum $status): self
  80. {
  81. $this->status = $status;
  82. return $this;
  83. }
  84. public function getStatus(): MessageStatusEnum
  85. {
  86. return $this->status;
  87. }
  88. public function setDateSent(\DateTimeInterface $dateSent): self
  89. {
  90. $this->dateSent = $dateSent;
  91. return $this;
  92. }
  93. public function getDateSent(): ?\DateTimeInterface
  94. {
  95. return $this->dateSent;
  96. }
  97. }