4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-15 13:46:37 +00:00
AzuraCast/src/Entity/Relay.php

125 lines
2.8 KiB
PHP
Raw Normal View History

<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Annotations as OA;
/** @OA\Schema(type="object") */
#[
ORM\Entity,
ORM\Table(name: 'relays'),
ORM\HasLifecycleCallbacks
]
class Relay
{
use Traits\HasAutoIncrementId;
use Traits\TruncateStrings;
2021-06-10 03:22:13 +00:00
/** @OA\Property(example="https://custom-url.example.com") */
#[ORM\Column(length: 255)]
protected string $base_url;
/** @OA\Property(example="Relay") */
#[ORM\Column(length: 100, nullable: true)]
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;
public function __construct(string $base_url)
{
2020-03-29 07:16:41 +00:00
$this->base_url = $this->truncateString($base_url);
$this->created_at = time();
$this->updated_at = time();
$this->remotes = new ArrayCollection();
}
#[ORM\PreUpdate]
public function preUpdate(): void
{
$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
{
$this->name = $this->truncateNullableString($name, 100);
}
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
{
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
public function getRemotes(): Collection
{
return $this->remotes;
}
}