src/Entity/MessageLog.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\ToArray;
  4. use App\Repository\MessageLogRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=MessageLogRepository::class)
  10.  */
  11. class MessageLog
  12. {
  13.     use ToArray;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="datetime")
  22.      */
  23.     private $createdAt;
  24.     /**
  25.      * @ORM\Column(type="guid", unique=true)
  26.      */
  27.     private $messageId;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=Conversation::class)
  30.      */
  31.     private $conversation;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=User::class)
  34.      */
  35.     private $sender;
  36.     /**
  37.      * @ORM\Column(type="enum", options={"values"="message_log_enum"})
  38.      */
  39.     private $type;
  40.     /**
  41.      * @ORM\Column(type="text", nullable=true)
  42.      */
  43.     private $payload;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity=DeliveryState::class, mappedBy="message")
  46.      */
  47.     private $deliveryStates;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.         $this->deliveryStates = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getCreatedAt(): ?\DateTimeInterface
  58.     {
  59.         return $this->createdAt;
  60.     }
  61.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  62.     {
  63.         $this->createdAt $createdAt;
  64.         return $this;
  65.     }
  66.     public function getMessageId(): ?string
  67.     {
  68.         return $this->messageId;
  69.     }
  70.     public function setMessageId(string $messageId): self
  71.     {
  72.         $this->messageId $messageId;
  73.         return $this;
  74.     }
  75.     public function getConversation(): ?Conversation
  76.     {
  77.         return $this->conversation;
  78.     }
  79.     public function setConversation(?Conversation $conversation): self
  80.     {
  81.         $this->conversation $conversation;
  82.         return $this;
  83.     }
  84.     public function getSender(): ?User
  85.     {
  86.         return $this->sender;
  87.     }
  88.     public function setSender(?User $sender): self
  89.     {
  90.         $this->sender $sender;
  91.         return $this;
  92.     }
  93.     public function getType()
  94.     {
  95.         return $this->type;
  96.     }
  97.     public function setType($type): self
  98.     {
  99.         $this->type $type;
  100.         return $this;
  101.     }
  102.     public function getPayload(): ?array
  103.     {
  104.         return json_decode($this->payloadtrue);
  105.     }
  106.     public function setPayload(?array $payload): self
  107.     {
  108.         $this->payload json_encode($payloadJSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES);
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection<int, DeliveryState>
  113.      */
  114.     public function getDeliveryStates(): Collection
  115.     {
  116.         return $this->deliveryStates;
  117.     }
  118.     public function addDeliveryState(DeliveryState $deliveryState): self
  119.     {
  120.         if (!$this->deliveryStates->contains($deliveryState)) {
  121.             $this->deliveryStates[] = $deliveryState;
  122.             $deliveryState->setMessage($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeDeliveryState(DeliveryState $deliveryState): self
  127.     {
  128.         if ($this->deliveryStates->removeElement($deliveryState)) {
  129.             // set the owning side to null (unless already changed)
  130.             if ($deliveryState->getMessage() === $this) {
  131.                 $deliveryState->setMessage(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136. }