2019-07-15 04:47:39 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
2020-12-08 18:40:33 +00:00
|
|
|
|
2019-07-15 04:47:39 +00:00
|
|
|
namespace App\Entity;
|
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
use App\Entity\Interfaces\IdentifiableEntityInterface;
|
2021-12-29 21:19:34 +00:00
|
|
|
use App\OpenApi;
|
2019-07-15 04:47:39 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2021-12-28 18:26:41 +00:00
|
|
|
use OpenApi\Attributes as OA;
|
2019-07-15 04:47:39 +00:00
|
|
|
|
2021-05-30 18:55:26 +00:00
|
|
|
#[
|
2021-12-19 18:50:37 +00:00
|
|
|
OA\Schema(type: "object"),
|
2021-05-30 18:55:26 +00:00
|
|
|
ORM\Entity,
|
|
|
|
ORM\Table(name: 'relays'),
|
|
|
|
ORM\HasLifecycleCallbacks
|
|
|
|
]
|
2021-07-19 05:53:45 +00:00
|
|
|
class Relay implements IdentifiableEntityInterface
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
2021-05-30 18:55:26 +00:00
|
|
|
use Traits\HasAutoIncrementId;
|
2019-07-15 04:47:39 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2021-12-19 18:50:37 +00:00
|
|
|
#[
|
|
|
|
OA\Property(example: "https://custom-url.example.com"),
|
|
|
|
ORM\Column(length: 255)
|
|
|
|
]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected string $base_url;
|
|
|
|
|
2021-12-19 18:50:37 +00:00
|
|
|
#[
|
|
|
|
OA\Property(example: "Relay"),
|
|
|
|
ORM\Column(length: 100, nullable: true)
|
|
|
|
]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected ?string $name = 'Relay';
|
|
|
|
|
2021-12-19 18:50:37 +00:00
|
|
|
#[
|
|
|
|
OA\Property(example: true),
|
|
|
|
ORM\Column
|
|
|
|
]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected bool $is_visible_on_public_pages = true;
|
|
|
|
|
|
|
|
#[ORM\Column(type: 'array', nullable: true)]
|
|
|
|
protected mixed $nowplaying;
|
|
|
|
|
2021-12-19 18:50:37 +00:00
|
|
|
#[
|
2021-12-29 21:19:34 +00:00
|
|
|
OA\Property(example: OpenApi::SAMPLE_TIMESTAMP),
|
2021-12-19 18:50:37 +00:00
|
|
|
ORM\Column
|
|
|
|
]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected int $created_at;
|
|
|
|
|
2021-12-19 18:50:37 +00:00
|
|
|
#[
|
2021-12-29 21:19:34 +00:00
|
|
|
OA\Property(example: OpenApi::SAMPLE_TIMESTAMP),
|
2021-12-19 18:50:37 +00:00
|
|
|
ORM\Column
|
|
|
|
]
|
2021-05-30 18:55:26 +00:00
|
|
|
protected int $updated_at;
|
|
|
|
|
2022-05-31 11:41:35 +00:00
|
|
|
/** @var Collection<int, StationRemote> */
|
2021-05-30 18:55:26 +00:00
|
|
|
#[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();
|
|
|
|
}
|
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
public function getBaseUrl(): string
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-11-07 05:02:44 +00:00
|
|
|
public function getIsVisibleOnPublicPages(): bool
|
2019-07-15 23:47:05 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
public function setNowplaying(mixed $nowplaying): void
|
2019-07-15 04:47:39 +00:00
|
|
|
{
|
|
|
|
$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
|
|
|
|
2022-05-31 11:41:35 +00:00
|
|
|
/**
|
|
|
|
* @return Collection<int, StationRemote>
|
|
|
|
*/
|
2019-07-15 04:47:39 +00:00
|
|
|
public function getRemotes(): Collection
|
|
|
|
{
|
|
|
|
return $this->remotes;
|
|
|
|
}
|
|
|
|
}
|