2018-09-21 14:04:05 +02:00
|
|
|
<?php
|
2020-10-15 00:19:31 +02:00
|
|
|
|
2021-07-19 07:53:45 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-09-22 13:52:43 +02:00
|
|
|
namespace App\Event\Radio;
|
2018-09-21 14:04:05 +02:00
|
|
|
|
|
|
|
use App\Entity\Station;
|
2022-06-22 03:48:32 +02:00
|
|
|
use App\Radio\Adapters;
|
|
|
|
use App\Radio\Frontend\AbstractFrontend;
|
2020-07-03 22:24:04 +02:00
|
|
|
use NowPlaying\Result\Result;
|
2019-08-07 06:33:55 +02:00
|
|
|
use Symfony\Contracts\EventDispatcher\Event;
|
2018-09-21 14:04:05 +02:00
|
|
|
|
|
|
|
class GenerateRawNowPlaying extends Event
|
|
|
|
{
|
2020-07-03 22:24:04 +02:00
|
|
|
protected ?Result $result = null;
|
2018-09-21 14:04:05 +02:00
|
|
|
|
|
|
|
public function __construct(
|
2022-06-22 03:48:32 +02:00
|
|
|
protected Adapters $adapters,
|
2021-04-23 07:24:12 +02:00
|
|
|
protected Station $station,
|
|
|
|
protected bool $include_clients = false
|
2018-09-21 14:04:05 +02:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStation(): Station
|
|
|
|
{
|
|
|
|
return $this->station;
|
|
|
|
}
|
|
|
|
|
2022-06-22 03:48:32 +02:00
|
|
|
public function getFrontend(): ?AbstractFrontend
|
2018-09-21 14:04:05 +02:00
|
|
|
{
|
2022-06-22 03:48:32 +02:00
|
|
|
return $this->adapters->getFrontendAdapter($this->station);
|
2018-09-21 14:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getRemotes(): array
|
|
|
|
{
|
2022-06-22 03:48:32 +02:00
|
|
|
$remotes = [];
|
|
|
|
foreach ($this->station->getRemotes() as $remote) {
|
|
|
|
$remotes[] = [
|
|
|
|
$remote,
|
|
|
|
$this->adapters->getRemoteAdapter($this->station, $remote),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return $remotes;
|
2018-09-21 14:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function includeClients(): bool
|
|
|
|
{
|
|
|
|
return $this->include_clients;
|
|
|
|
}
|
|
|
|
|
2020-07-03 22:24:04 +02:00
|
|
|
public function getResult(): Result
|
2018-09-21 14:04:05 +02:00
|
|
|
{
|
2020-07-03 22:24:04 +02:00
|
|
|
return $this->result ?? Result::blank();
|
2018-09-21 14:04:05 +02:00
|
|
|
}
|
|
|
|
|
2020-07-03 22:24:04 +02:00
|
|
|
public function setResult(Result $result): void
|
2018-09-21 14:04:05 +02:00
|
|
|
{
|
2020-07-03 22:24:04 +02:00
|
|
|
$this->result = $result;
|
2018-09-21 14:04:05 +02:00
|
|
|
}
|
|
|
|
}
|