2019-07-15 04:47:39 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2020-12-08 18:40:33 +00:00
|
|
|
/** @noinspection PhpMissingFieldTypeInspection */
|
|
|
|
|
2019-07-15 04:47:39 +00:00
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use OpenApi\Annotations as OA;
|
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
/** @OA\Schema(type="object") */
|
|
|
|
#[
|
|
|
|
ORM\Entity,
|
|
|
|
ORM\Table(name: 'relays'),
|
|
|
|
ORM\HasLifecycleCallbacks
|
|
|
|
]
|
2019-07-15 04:47:39 +00:00
|
|
|
class Relay
|
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
use Traits\HasAutoIncrementId;
|
2019-07-15 04:47:39 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2021-06-10 03:22:13 +00:00
|
|
|
/** @OA\Property(example="https://custom-url.example.com") */
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\Column(length: 255)]
|
|
|
|
protected string $base_url;
|
|
|
|
|
|
|
|
/** @OA\Property(example="Relay") */
|
2021-06-09 01:38:18 +00:00
|
|
|
#[ORM\Column(length: 100, nullable: true)]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected ?string $name = 'Relay';
|
|
|
|
|
|
|
|
/** @OA\Property(example=true) */
|
|
|
|
#[ORM\Column]
|
|
|
|
protected bool $is_visible_on_public_pages = true;
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'array', nullable: true)]
|
|
|
|
protected mixed $nowplaying;
|
|
|
|
|
|
|
|
/** @OA\Property(example=SAMPLE_TIMESTAMP) */
|
|
|
|
#[ORM\Column]
|
|
|
|
protected int $created_at;
|
|
|
|
|
|
|
|
/** @OA\Property(example=SAMPLE_TIMESTAMP) */
|
|
|
|
#[ORM\Column]
|
|
|
|
protected int $updated_at;
|
|
|
|
|
|
|
|
#[ORM\OneToMany(mappedBy: 'relay', targetEntity: StationRemote::class)]
|
|
|
|
protected Collection $remotes;
|
2019-07-15 04:47:39 +00:00
|
|
|
|
2019-07-15 23:47:05 +00:00
|
|
|
public function __construct(string $base_url)
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->base_url = $this->truncateString($base_url);
|
2019-07-15 04:47:39 +00:00
|
|
|
|
|
|
|
$this->created_at = time();
|
|
|
|
$this->updated_at = time();
|
|
|
|
|
2020-10-14 22:19:31 +00:00
|
|
|
$this->remotes = new ArrayCollection();
|
2019-07-15 04:47:39 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[ORM\PreUpdate]
|
2019-08-12 05:03:00 +00:00
|
|
|
public function preUpdate(): void
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
|
|
|
$this->updated_at = time();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->base_url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName(?string $name): void
|
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
$this->name = $this->truncateNullableString($name, 100);
|
2019-07-15 04:47:39 +00:00
|
|
|
}
|
|
|
|
|
2019-07-15 23:47:05 +00:00
|
|
|
public function isIsVisibleOnPublicPages(): bool
|
|
|
|
{
|
|
|
|
return $this->is_visible_on_public_pages;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
|
|
|
|
{
|
|
|
|
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
|
|
|
|
}
|
|
|
|
|
2021-04-23 02:16:00 +00:00
|
|
|
public function getNowplaying(): mixed
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
|
|
|
return $this->nowplaying;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNowplaying($nowplaying): void
|
|
|
|
{
|
|
|
|
$this->nowplaying = $nowplaying;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreatedAt(): int
|
|
|
|
{
|
|
|
|
return $this->created_at;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCreatedAt(int $created_at): void
|
|
|
|
{
|
|
|
|
$this->created_at = $created_at;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUpdatedAt(): int
|
|
|
|
{
|
|
|
|
return $this->updated_at;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUpdatedAt(int $updated_at): void
|
|
|
|
{
|
|
|
|
$this->updated_at = $updated_at;
|
|
|
|
}
|
2020-07-09 02:32:34 +00:00
|
|
|
|
2019-07-15 04:47:39 +00:00
|
|
|
public function getRemotes(): Collection
|
|
|
|
{
|
|
|
|
return $this->remotes;
|
|
|
|
}
|
|
|
|
}
|