src/Database/Domain/Entity/Sessions/ToastSessionSection.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Database\Domain\Entity\Sessions;
  4. use App\Database\Domain\Entity\AbstractEntity;
  5. use App\Database\Domain\Entity\User\User;
  6. use App\Database\Domain\Traits\CreationDateTrait;
  7. use App\Database\Domain\Traits\OrderIndexTrait;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @ORM\Entity(repositoryClass="App\Database\Domain\Repository\ToastSessionRepository")
  15.  */
  16. class ToastSessionSection extends AbstractEntity
  17. {
  18.     use CreationDateTrait;
  19.     use OrderIndexTrait;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="App\Database\Domain\Entity\User\User", inversedBy="sections")
  22.      *
  23.      * @ORM\JoinColumn(onDelete="CASCADE")
  24.      */
  25.     private User $user;
  26.     /**
  27.      * @ORM\Column(type="string")
  28.      *
  29.      * @Assert\Length(max="255")
  30.      *
  31.      * @Groups({"toast_session_section"})
  32.      */
  33.     private string $name '';
  34.     /**
  35.      * @ORM\Column(type="string", nullable=true)
  36.      *
  37.      * @Assert\Length(max="5")
  38.      *
  39.      * @Groups({"toast_session_section"})
  40.      */
  41.     private ?string $emoji null;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity="App\Database\Domain\Entity\Sessions\ToastSession", mappedBy="section", fetch="EXTRA_LAZY")
  44.      *
  45.      * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="write_rare")
  46.      *
  47.      * @var Collection<int, ToastSession>
  48.      */
  49.     private Collection $sessions;
  50.     /**
  51.      * @ORM\Column(type="string", nullable=true)
  52.      *
  53.      * @Groups({"toast_session_section"})
  54.      */
  55.     private ?string $browserId;
  56.     public function __construct(User $user)
  57.     {
  58.         $this->user $user;
  59.         $this->orderIndex 0;
  60.         $this->sessions = new ArrayCollection();
  61.         $this->creationDate = new \DateTimeImmutable();
  62.     }
  63.     public function getName(): string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): void
  68.     {
  69.         $this->name $name;
  70.     }
  71.     public function getEmoji(): ?string
  72.     {
  73.         if (!$this->emoji) {
  74.             return $this->emoji;
  75.         }
  76.         return mb_convert_encoding($this->emoji'UTF-8''UTF-8');
  77.     }
  78.     public function setEmoji(?string $emoji): void
  79.     {
  80.         $this->emoji $emoji;
  81.     }
  82.     public function getSessions(): Collection
  83.     {
  84.         return $this->sessions;
  85.     }
  86.     public function setSessions(Collection $sessions): void
  87.     {
  88.         $this->sessions $sessions;
  89.     }
  90.     public function getUser(): User
  91.     {
  92.         return $this->user;
  93.     }
  94.     public function setUser(User $user): void
  95.     {
  96.         $this->user $user;
  97.     }
  98.     public function getBrowserId(): ?string
  99.     {
  100.         return $this->browserId;
  101.     }
  102.     public function setBrowserId(?string $browserId): void
  103.     {
  104.         $this->browserId $browserId;
  105.     }
  106. }