src/Database/Domain/Entity/Sessions/ToastSession.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Database\Domain\Entity\Sessions;
  3. use App\Database\Domain\Entity\AbstractEntity;
  4. use App\Database\Domain\Entity\User\User;
  5. use App\Database\Domain\Traits\CreationDateTrait;
  6. use App\Database\Domain\Traits\OrderIndexTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Database\Domain\Repository\ToastSessionRepository")
  13.  */
  14. class ToastSession extends AbstractEntity
  15. {
  16.     use CreationDateTrait;
  17.     use OrderIndexTrait;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity="App\Database\Domain\Entity\User\User", inversedBy="sessions")
  20.      *
  21.      * @ORM\JoinColumn(onDelete="CASCADE")
  22.      */
  23.     private User $user;
  24.     /**
  25.      * @ORM\Column(type="string")
  26.      *
  27.      * @Assert\Length(max="255")
  28.      */
  29.     private string $name;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity="App\Database\Domain\Entity\Sessions\ToastSessionLink", mappedBy="session", fetch="EXTRA_LAZY", cascade={"all"})
  32.      *
  33.      * @ORM\OrderBy({"orderIndex": "ASC"})
  34.      *
  35.      * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="write_rare")
  36.      *
  37.      * @var Collection<int, ToastSessionLink>
  38.      */
  39.     private Collection $links;
  40.     /**
  41.      * @ORM\Column(type="string", nullable=true)
  42.      */
  43.     private ?string $browserId;
  44.     /**
  45.      * @ORM\Column(type="boolean")
  46.      */
  47.     private bool $isEnabled;
  48.     /**
  49.      * @ORM\Column(type="string", nullable=false, unique=true)
  50.      */
  51.     private string $shareSlug;
  52.     /**
  53.      * @ORM\Column(type="boolean", nullable=false, options={"default": 0})
  54.      */
  55.     private bool $enabledForCollaboration;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity="App\Database\Domain\Entity\Sessions\ToastSessionSection", inversedBy="sessions")
  58.      *
  59.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  60.      */
  61.     private ?ToastSessionSection $section null;
  62.     /**
  63.      * @ORM\Column(type="string", nullable=true)
  64.      *
  65.      * @Assert\Length(max="5")
  66.      */
  67.     private ?string $emoji null;
  68.     public function __construct(
  69.         string $id,
  70.         string $name,
  71.         string $shareSlug,
  72.         User $user,
  73.         ?string $browserId null,
  74.         bool $isEnabled true
  75.     ) {
  76.         $this->id $id;
  77.         $this->name $name;
  78.         $this->shareSlug $shareSlug;
  79.         $this->user $user;
  80.         $this->browserId $browserId;
  81.         $this->isEnabled $isEnabled;
  82.         $this->creationDate = new \DateTimeImmutable();
  83.         $this->links = new ArrayCollection();
  84.         $this->orderIndex 0;
  85.         $this->enabledForCollaboration false;
  86.     }
  87.     public function __toString(): string
  88.     {
  89.         return $this->id;
  90.     }
  91.     public function getUser(): User
  92.     {
  93.         return $this->user;
  94.     }
  95.     public function setUser(User $user): self
  96.     {
  97.         $this->user $user;
  98.         return $this;
  99.     }
  100.     public function getName(): string
  101.     {
  102.         return $this->name;
  103.     }
  104.     public function setName(string $name): self
  105.     {
  106.         $this->name $name;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return ToastSessionLink[]
  111.      */
  112.     public function getLinks(): Collection
  113.     {
  114.         return $this->links;
  115.     }
  116.     public function addLink(ToastSessionLink $link): self
  117.     {
  118.         $this->links[] = $link;
  119.         return $this;
  120.     }
  121.     public function getBrowserId(): ?string
  122.     {
  123.         return $this->browserId;
  124.     }
  125.     public function setBrowserId(?string $browserId): self
  126.     {
  127.         $this->browserId $browserId;
  128.         return $this;
  129.     }
  130.     public function isEnabled(): bool
  131.     {
  132.         return $this->isEnabled;
  133.     }
  134.     public function setIsEnabled(bool $isEnabled): self
  135.     {
  136.         $this->isEnabled $isEnabled;
  137.         return $this;
  138.     }
  139.     public function getShareSlug(): string
  140.     {
  141.         return $this->shareSlug;
  142.     }
  143.     public function setShareSlug(string $shareSlug): self
  144.     {
  145.         $this->shareSlug $shareSlug;
  146.         return $this;
  147.     }
  148.     public function isEnabledForCollaboration(): bool
  149.     {
  150.         return $this->enabledForCollaboration;
  151.     }
  152.     public function setEnabledForCollaboration(bool $enabledForCollaboration): void
  153.     {
  154.         $this->enabledForCollaboration $enabledForCollaboration;
  155.     }
  156.     public function getEmoji(): ?string
  157.     {
  158.         return $this->emoji;
  159.     }
  160.     public function setEmoji(?string $emoji): void
  161.     {
  162.         $this->emoji $emoji;
  163.     }
  164.     public function getSection(): ?ToastSessionSection
  165.     {
  166.         return $this->section;
  167.     }
  168.     public function setSection(?ToastSessionSection $section): void
  169.     {
  170.         $this->section $section;
  171.     }
  172. }