src/Database/Domain/Entity/Sessions/ActiveSessions/ActiveDevice.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Database\Domain\Entity\Sessions\ActiveSessions;
  3. use App\Database\Domain\Entity\AbstractEntity;
  4. use App\Database\Domain\Entity\User\User;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity()
  10.  */
  11. class ActiveDevice extends AbstractEntity
  12. {
  13.     /**
  14.      * @ORM\Column(type="string")
  15.      */
  16.     private string $name;
  17.     /**
  18.      * @ORM\Column(type="string")
  19.      */
  20.     private string $deviceId;
  21.     /**
  22.      * @ORM\Column(type="boolean")
  23.      */
  24.     private bool $syncEnabled;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Database\Domain\Entity\Sessions\ActiveSessions\ActiveSession", inversedBy="devices")
  27.      *
  28.      * @ORM\JoinColumn(onDelete="CASCADE")
  29.      */
  30.     private ActiveSession $session;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity="App\Database\Domain\Entity\Sessions\ActiveSessions\ActiveSessionTab", mappedBy="device", cascade={"all"})
  33.      *
  34.      * @ORM\OrderBy({"orderIndex": "ASC"})
  35.      *
  36.      * @var Collection<int, ActiveSessionTab>
  37.      */
  38.     private Collection $tabs;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="App\Database\Domain\Entity\User\User")
  41.      *
  42.      * @ORM\JoinColumn(onDelete="CASCADE")
  43.      */
  44.     private ?User $user null;
  45.     public function __construct($idUser $userActiveSession $activeSessionstring $namestring $deviceId)
  46.     {
  47.         $this->id $id;
  48.         $this->session $activeSession;
  49.         $this->name $name;
  50.         $this->deviceId $deviceId;
  51.         $this->syncEnabled true;
  52.         $this->tabs = new ArrayCollection();
  53.         $this->user $user;
  54.     }
  55.     public function changeName(string $name)
  56.     {
  57.         $this->name $name;
  58.     }
  59.     public function toggleSync()
  60.     {
  61.         $this->syncEnabled = !$this->syncEnabled;
  62.     }
  63.     public function getName(): string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function getDeviceId(): string
  68.     {
  69.         return $this->deviceId;
  70.     }
  71.     public function isSyncEnabled(): bool
  72.     {
  73.         return $this->syncEnabled;
  74.     }
  75.     /**
  76.      * @return ActiveSessionTab[]
  77.      */
  78.     public function getTabs(): Collection
  79.     {
  80.         return $this->tabs;
  81.     }
  82.     public function getSession(): ActiveSession
  83.     {
  84.         return $this->session;
  85.     }
  86.     public function getUser(): ?User
  87.     {
  88.         return $this->user;
  89.     }
  90.     public function setUser(User $user): void
  91.     {
  92.         $this->user $user;
  93.     }
  94. }