2015-01-02 08:16:54 +00:00
|
|
|
<?php
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Entity;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
use App\Radio\Frontend\FrontendAbstract;
|
2018-09-22 11:52:43 +00:00
|
|
|
use App\Radio\Remote\AdapterProxy;
|
2018-09-09 18:23:03 +00:00
|
|
|
use App\Radio\Remote\RemoteAbstract;
|
2017-01-24 00:35:16 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2017-08-17 18:28:48 +00:00
|
|
|
use Doctrine\Common\Collections\Collection;
|
2017-09-07 03:53:25 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
2018-10-04 23:12:12 +00:00
|
|
|
use GuzzleHttp\Psr7\Uri;
|
2016-09-27 21:54:19 +00:00
|
|
|
use Interop\Container\ContainerInterface;
|
2018-10-04 23:12:12 +00:00
|
|
|
use Psr\Http\Message\UriInterface;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Table(name="station")
|
2018-08-04 22:05:14 +00:00
|
|
|
* @Entity(repositoryClass="App\Entity\Repository\StationRepository")
|
2015-02-26 05:01:02 +00:00
|
|
|
* @HasLifecycleCallbacks
|
2015-01-02 08:16:54 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
class Station
|
2015-01-02 08:16:54 +00:00
|
|
|
{
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_REQUEST_DELAY = 5;
|
|
|
|
public const DEFAULT_REQUEST_THRESHOLD = 15;
|
2018-10-27 00:14:32 +00:00
|
|
|
public const DEFAULT_DISCONNECT_DEACTIVATE_STREAMER = 0;
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_API_HISTORY_ITEMS = 5;
|
2018-08-18 23:01:03 +00:00
|
|
|
|
2018-04-06 21:29:27 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="id", type="integer")
|
|
|
|
* @Id
|
|
|
|
* @GeneratedValue(strategy="IDENTITY")
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="name", type="string", length=100, nullable=true)
|
2017-12-08 09:51:08 +00:00
|
|
|
* @var string|null The full display name of the station.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $name;
|
|
|
|
|
2017-12-08 09:51:08 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="short_name", type="string", length=100, nullable=true)
|
|
|
|
* @var string|null The URL-friendly name for the station, typically auto-generated from the full station name.
|
|
|
|
*/
|
|
|
|
protected $short_name;
|
|
|
|
|
2018-03-24 07:38:27 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="is_enabled", type="boolean", nullable=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool If set to "false", prevents the station from broadcasting but leaves it in the database.
|
2018-03-24 07:38:27 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $is_enabled = true;
|
2018-03-24 07:38:27 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="frontend_type", type="string", length=100, nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var string|null The frontend adapter (icecast,shoutcast,remote,etc)
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $frontend_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="frontend_config", type="json_array", nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var array|null An array containing station-specific frontend configuration
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $frontend_config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="backend_type", type="string", length=100, nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var string|null The backend adapter (liquidsoap,etc)
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $backend_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="backend_config", type="json_array", nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var array|null An array containing station-specific backend configuration
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $backend_config;
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="adapter_api_key", type="string", length=150, nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var string|null An internal-use API key used for container-to-container communications from Liquidsoap to AzuraCast
|
2017-09-07 03:53:25 +00:00
|
|
|
*/
|
|
|
|
protected $adapter_api_key;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="description", type="text", nullable=true)
|
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $description;
|
|
|
|
|
|
|
|
/**
|
2017-08-29 03:44:51 +00:00
|
|
|
* @Column(name="url", type="string", length=255, nullable=true)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $url;
|
|
|
|
|
2018-11-26 08:16:55 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="genre", type="string", length=150, nullable=true)
|
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $genre;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2017-08-29 03:44:51 +00:00
|
|
|
* @Column(name="radio_base_dir", type="string", length=255, nullable=true)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $radio_base_dir;
|
|
|
|
|
|
|
|
/**
|
2017-08-29 03:44:51 +00:00
|
|
|
* @Column(name="radio_media_dir", type="string", length=255, nullable=true)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $radio_media_dir;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="nowplaying", type="array", nullable=true)
|
|
|
|
* @var mixed|null
|
|
|
|
*/
|
|
|
|
protected $nowplaying;
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="nowplaying_timestamp", type="integer", nullable=true)
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $nowplaying_timestamp;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="automation_settings", type="json_array", nullable=true)
|
|
|
|
* @var array|null
|
|
|
|
*/
|
|
|
|
protected $automation_settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="automation_timestamp", type="integer", nullable=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var int|null The UNIX timestamp when station automation was most recently run.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $automation_timestamp = 0;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="enable_requests", type="boolean", nullable=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether listeners can request songs to play on this station.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_requests = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="request_delay", type="integer", nullable=true)
|
|
|
|
* @var int|null
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $request_delay = self::DEFAULT_REQUEST_DELAY;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="request_threshold", type="integer", nullable=true)
|
|
|
|
* @var int|null
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $request_threshold = self::DEFAULT_REQUEST_THRESHOLD;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
/**
|
2018-11-20 10:08:34 +00:00
|
|
|
* @Column(name="disconnect_deactivate_streamer", type="integer", nullable=true, options={"default":0})
|
2018-10-27 00:14:32 +00:00
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $disconnect_deactivate_streamer = self::DEFAULT_DISCONNECT_DEACTIVATE_STREAMER;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="enable_streamers", type="boolean", nullable=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether streamers are allowed to broadcast to this station at all.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_streamers = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="is_streamer_live", type="boolean", nullable=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether a streamer is currently active on the station.
|
2018-02-03 21:54:12 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $is_streamer_live = false;
|
2018-02-03 21:54:12 +00:00
|
|
|
|
2017-09-18 03:27:32 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="enable_public_page", type="boolean", nullable=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether this station is visible as a public page and in a now-playing API response.
|
2017-09-18 03:27:32 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_public_page = true;
|
2017-09-18 03:27:32 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="needs_restart", type="boolean")
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether to show the "Restart station to apply changes" sidebar for this station
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $needs_restart = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="has_started", type="boolean")
|
|
|
|
* @var bool
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $has_started = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(name="api_history_items", type="smallint")
|
|
|
|
* @var int|null The number of "last played" history items to show for a given station in the Now Playing API responses.
|
|
|
|
*/
|
|
|
|
protected $api_history_items = self::DEFAULT_API_HISTORY_ITEMS;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="SongHistory", mappedBy="station")
|
|
|
|
* @OrderBy({"timestamp" = "DESC"})
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $history;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationMedia", mappedBy="station")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $media;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationStreamer", mappedBy="station")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $streamers;
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="current_streamer_id", type="integer", nullable=true)
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $current_streamer_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ManyToOne(targetEntity="StationStreamer")
|
|
|
|
* @JoinColumns({
|
2018-03-20 16:37:18 +00:00
|
|
|
* @JoinColumn(name="current_streamer_id", referencedColumnName="id", onDelete="SET NULL")
|
2018-02-03 21:54:12 +00:00
|
|
|
* })
|
|
|
|
* @var StationStreamer|null
|
|
|
|
*/
|
|
|
|
protected $current_streamer;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="RolePermission", mappedBy="station")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $permissions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationPlaylist", mappedBy="station")
|
|
|
|
* @OrderBy({"type" = "ASC","weight" = "DESC"})
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $playlists;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationMount", mappedBy="station")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $mounts;
|
|
|
|
|
2018-09-09 18:23:03 +00:00
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationRemote", mappedBy="station")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $remotes;
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="StationWebhook", mappedBy="station", fetch="EXTRA_LAZY")
|
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $webhooks;
|
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->history = new ArrayCollection;
|
|
|
|
$this->media = new ArrayCollection;
|
|
|
|
$this->playlists = new ArrayCollection;
|
|
|
|
$this->mounts = new ArrayCollection;
|
2018-09-09 18:23:03 +00:00
|
|
|
$this->remotes = new ArrayCollection;
|
2018-02-12 12:46:03 +00:00
|
|
|
$this->webhooks = new ArrayCollection;
|
2017-01-24 00:17:50 +00:00
|
|
|
$this->streamers = new ArrayCollection;
|
|
|
|
}
|
|
|
|
|
2015-01-02 08:16:54 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return int
|
2015-01-02 08:16:54 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getId(): int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2017-12-08 09:51:08 +00:00
|
|
|
* @param null|string $name
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-04-06 21:29:27 +00:00
|
|
|
public function setName(?string $name = null)
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->name = $this->_truncateString($name, 100);
|
2017-12-08 09:51:08 +00:00
|
|
|
|
|
|
|
if (empty($this->short_name) && !empty($name)) {
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->setShortName(self::getStationShortName($name));
|
2017-12-08 09:51:08 +00:00
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2017-12-08 09:51:08 +00:00
|
|
|
* @return null|string
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2017-12-08 09:51:08 +00:00
|
|
|
public function getShortName(): ?string
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2017-12-09 17:29:27 +00:00
|
|
|
return (!empty($this->short_name))
|
|
|
|
? $this->short_name
|
|
|
|
: self::getStationShortName($this->name);
|
2017-12-08 09:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param null|string $short_name
|
|
|
|
*/
|
|
|
|
public function setShortName(?string $short_name): void
|
|
|
|
{
|
2017-12-09 17:29:27 +00:00
|
|
|
$short_name = trim($short_name);
|
|
|
|
if (!empty($short_name)) {
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->short_name = $this->_truncateString($short_name, 100);
|
2017-12-09 17:29:27 +00:00
|
|
|
}
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2015-02-16 07:46:37 +00:00
|
|
|
|
2018-03-24 07:38:27 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isEnabled(): bool
|
|
|
|
{
|
|
|
|
return $this->is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $is_enabled
|
|
|
|
*/
|
|
|
|
public function setIsEnabled(bool $is_enabled): void
|
|
|
|
{
|
|
|
|
$this->is_enabled = $is_enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getFrontendType(): ?string
|
|
|
|
{
|
|
|
|
return $this->frontend_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param null|string $frontend_type
|
|
|
|
*/
|
|
|
|
public function setFrontendType(string $frontend_type = null)
|
|
|
|
{
|
|
|
|
$this->frontend_type = $frontend_type;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return array|null
|
|
|
|
*/
|
|
|
|
public function getFrontendConfig(): ?array
|
|
|
|
{
|
|
|
|
return $this->frontend_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $frontend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
2017-08-04 11:46:30 +00:00
|
|
|
public function setFrontendConfig($frontend_config, $force_overwrite = false)
|
|
|
|
{
|
|
|
|
$config = ($force_overwrite) ? [] : (array)$this->frontend_config;
|
|
|
|
foreach((array)$frontend_config as $cfg_key => $cfg_val) {
|
|
|
|
$config[$cfg_key] = $cfg_val;
|
|
|
|
}
|
2018-05-01 14:37:52 +00:00
|
|
|
|
|
|
|
if ($this->frontend_config !== $config) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
2017-08-04 11:46:30 +00:00
|
|
|
$this->frontend_config = $config;
|
|
|
|
}
|
|
|
|
|
2018-03-10 15:37:35 +00:00
|
|
|
/**
|
|
|
|
* Set frontend configuration but do not overwrite existing values.
|
|
|
|
*
|
|
|
|
* @param $default_config
|
|
|
|
*/
|
|
|
|
public function setFrontendConfigDefaults($default_config)
|
|
|
|
{
|
|
|
|
$frontend_config = (array)$this->frontend_config;
|
|
|
|
|
|
|
|
foreach($default_config as $config_key => $config_value) {
|
|
|
|
if (empty($frontend_config[$config_key])) {
|
|
|
|
$frontend_config[$config_key] = $config_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->frontend_config = $frontend_config;
|
|
|
|
}
|
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return null|string
|
2017-01-24 00:17:50 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getBackendType(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->backend_type;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param null|string $backend_type
|
|
|
|
*/
|
|
|
|
public function setBackendType(string $backend_type = null)
|
|
|
|
{
|
|
|
|
$this->backend_type = $backend_type;
|
|
|
|
}
|
2015-02-17 12:23:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return array|null
|
|
|
|
*/
|
|
|
|
public function getBackendConfig(): ?array
|
|
|
|
{
|
|
|
|
return $this->backend_config;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param $backend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
2017-08-04 11:46:30 +00:00
|
|
|
public function setBackendConfig($backend_config, $force_overwrite = false)
|
|
|
|
{
|
|
|
|
$config = ($force_overwrite) ? [] : (array)$this->backend_config;
|
|
|
|
foreach((array)$backend_config as $cfg_key => $cfg_val) {
|
|
|
|
$config[$cfg_key] = $cfg_val;
|
|
|
|
}
|
2018-05-01 14:37:52 +00:00
|
|
|
|
|
|
|
if ($this->backend_config !== $config) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
2017-08-04 11:46:30 +00:00
|
|
|
$this->backend_config = $config;
|
|
|
|
}
|
|
|
|
|
2018-05-01 07:32:31 +00:00
|
|
|
/**
|
|
|
|
* Whether the station uses AzuraCast to directly manage the AutoDJ or lets the backend handle it.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function useManualAutoDJ(): bool
|
|
|
|
{
|
|
|
|
$settings = (array)$this->getBackendConfig();
|
2018-09-09 18:23:03 +00:00
|
|
|
return (bool)($settings['use_manual_autodj'] ?? false);
|
2018-05-01 07:32:31 +00:00
|
|
|
}
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getAdapterApiKey(): ?string
|
|
|
|
{
|
|
|
|
return $this->adapter_api_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a random new adapter API key.
|
|
|
|
*/
|
|
|
|
public function generateAdapterApiKey()
|
|
|
|
{
|
|
|
|
$this->adapter_api_key = bin2hex(random_bytes(50));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticate the supplied adapter API key.
|
|
|
|
*
|
|
|
|
* @param $api_key
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function validateAdapterApiKey($api_key)
|
|
|
|
{
|
|
|
|
return hash_equals($api_key, $this->adapter_api_key);
|
|
|
|
}
|
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return null|string
|
2017-01-24 00:17:50 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getDescription(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->description;
|
|
|
|
}
|
2017-01-24 00:35:16 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param null|string $description
|
|
|
|
*/
|
|
|
|
public function setDescription(string $description = null)
|
|
|
|
{
|
|
|
|
$this->description = $description;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->url;
|
|
|
|
}
|
2016-05-06 08:57:34 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param null|string $url
|
|
|
|
*/
|
|
|
|
public function setUrl(string $url = null)
|
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$this->url = $this->_truncateString($url);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2017-04-23 20:37:10 +00:00
|
|
|
|
2018-11-26 08:16:55 +00:00
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getGenre(): ?string
|
|
|
|
{
|
|
|
|
return $this->genre;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $genre
|
|
|
|
*/
|
|
|
|
public function setGenre(?string $genre): void
|
|
|
|
{
|
|
|
|
$this->genre = $this->_truncateString($genre, 150);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getRadioBaseDir(): ?string
|
|
|
|
{
|
|
|
|
return $this->radio_base_dir;
|
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param $new_dir
|
|
|
|
*/
|
2017-05-10 09:27:22 +00:00
|
|
|
public function setRadioBaseDir($new_dir)
|
2017-05-10 09:01:38 +00:00
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$new_dir = $this->_truncateString(trim($new_dir));
|
|
|
|
|
2017-05-10 09:27:22 +00:00
|
|
|
if (strcmp($this->radio_base_dir, $new_dir) !== 0) {
|
|
|
|
$this->radio_base_dir = $new_dir;
|
|
|
|
|
|
|
|
$radio_dirs = [
|
|
|
|
$this->radio_base_dir,
|
|
|
|
$this->getRadioMediaDir(),
|
|
|
|
$this->getRadioPlaylistsDir(),
|
|
|
|
$this->getRadioConfigDir()
|
|
|
|
];
|
|
|
|
foreach ($radio_dirs as $radio_dir) {
|
|
|
|
if (!file_exists($radio_dir)) {
|
2018-04-06 21:29:27 +00:00
|
|
|
if (!mkdir($radio_dir, 0777) && !is_dir($radio_dir)) {
|
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $radio_dir));
|
|
|
|
}
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-10 09:01:38 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRadioMediaDir(): string
|
|
|
|
{
|
|
|
|
return (!empty($this->radio_media_dir))
|
|
|
|
? $this->radio_media_dir
|
|
|
|
: $this->radio_base_dir.'/media';
|
|
|
|
}
|
|
|
|
|
2018-11-02 18:44:01 +00:00
|
|
|
/**
|
|
|
|
* Given an absolute path, return a path relative to this station's media directory.
|
|
|
|
*
|
|
|
|
* @param $full_path
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRelativeMediaPath($full_path): string
|
|
|
|
{
|
|
|
|
return ltrim(str_replace($this->getRadioMediaDir(), '', $full_path), '/');
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRadioPlaylistsDir(): string
|
|
|
|
{
|
|
|
|
return $this->radio_base_dir.'/playlists';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getRadioConfigDir(): string
|
|
|
|
{
|
|
|
|
return $this->radio_base_dir.'/config';
|
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param $new_dir
|
|
|
|
*/
|
2018-04-06 21:29:27 +00:00
|
|
|
public function setRadioMediaDir(?string $new_dir)
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2018-04-06 21:29:27 +00:00
|
|
|
$new_dir = $this->_truncateString(trim($new_dir));
|
2017-05-10 09:01:38 +00:00
|
|
|
|
2018-04-06 21:29:27 +00:00
|
|
|
if ($new_dir && $new_dir !== $this->radio_media_dir) {
|
2017-05-10 09:27:22 +00:00
|
|
|
if (!empty($new_dir) && !file_exists($new_dir)) {
|
2018-04-06 21:29:27 +00:00
|
|
|
if (!mkdir($new_dir, 0777, true) && !is_dir($new_dir)) {
|
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $new_dir));
|
|
|
|
}
|
2017-05-10 09:01:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->radio_media_dir = $new_dir;
|
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-02-12 12:46:03 +00:00
|
|
|
* @return Api\NowPlaying|null
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-02-12 12:46:03 +00:00
|
|
|
public function getNowplaying(): ?Api\NowPlaying
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2018-02-12 12:46:03 +00:00
|
|
|
if ($this->nowplaying instanceof Api\NowPlaying) {
|
|
|
|
return $this->nowplaying;
|
|
|
|
}
|
|
|
|
return null;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-02-12 12:46:03 +00:00
|
|
|
* @param Api\NowPlaying|null $nowplaying
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-02-12 12:46:03 +00:00
|
|
|
public function setNowplaying(Api\NowPlaying $nowplaying = null)
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->nowplaying = $nowplaying;
|
2018-02-12 12:46:03 +00:00
|
|
|
|
|
|
|
if ($nowplaying instanceof Api\NowPlaying) {
|
|
|
|
$this->nowplaying_timestamp = time();
|
|
|
|
}
|
2017-09-07 03:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getNowplayingTimestamp(): int
|
|
|
|
{
|
|
|
|
return (int)$this->nowplaying_timestamp;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return array|null
|
|
|
|
*/
|
|
|
|
public function getAutomationSettings(): ?array
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->automation_settings;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param array|null $automation_settings
|
|
|
|
*/
|
|
|
|
public function setAutomationSettings(array $automation_settings = null)
|
|
|
|
{
|
|
|
|
$this->automation_settings = $automation_settings;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function getAutomationTimestamp(): ?int
|
|
|
|
{
|
|
|
|
return $this->automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param int|null $automation_timestamp
|
|
|
|
*/
|
|
|
|
public function setAutomationTimestamp(int $automation_timestamp = null)
|
|
|
|
{
|
|
|
|
$this->automation_timestamp = $automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getEnableRequests(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_requests;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param bool $enable_requests
|
|
|
|
*/
|
|
|
|
public function setEnableRequests(bool $enable_requests)
|
|
|
|
{
|
|
|
|
$this->enable_requests = $enable_requests;
|
|
|
|
}
|
2016-09-04 23:24:53 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function getRequestDelay(): ?int
|
|
|
|
{
|
|
|
|
return $this->request_delay;
|
|
|
|
}
|
2017-04-14 21:03:59 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param int|null $request_delay
|
|
|
|
*/
|
|
|
|
public function setRequestDelay(int $request_delay = null)
|
|
|
|
{
|
|
|
|
$this->request_delay = $request_delay;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function getRequestThreshold()
|
|
|
|
{
|
|
|
|
return $this->request_threshold;
|
|
|
|
}
|
2016-11-20 04:00:25 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @param int|null $request_threshold
|
|
|
|
*/
|
|
|
|
public function setRequestThreshold(int $request_threshold = null)
|
|
|
|
{
|
|
|
|
$this->request_threshold = $request_threshold;
|
|
|
|
}
|
2017-06-06 18:07:18 +00:00
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getDisconnectDeactivateStreamer(): int
|
|
|
|
{
|
|
|
|
return $this->disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $disconnect_deactivate_streamer
|
|
|
|
*/
|
|
|
|
public function setDisconnectDeactivateStreamer(int $disconnect_deactivate_streamer)
|
|
|
|
{
|
|
|
|
$this->disconnect_deactivate_streamer = $disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
2015-01-02 08:16:54 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return bool
|
2015-01-02 08:16:54 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getEnableStreamers(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @param bool $enable_streamers
|
2015-01-02 08:16:54 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function setEnableStreamers(bool $enable_streamers)
|
|
|
|
{
|
|
|
|
$this->enable_streamers = $enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getIsStreamerLive(): bool
|
|
|
|
{
|
|
|
|
return $this->is_streamer_live;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $is_streamer_live
|
|
|
|
*/
|
|
|
|
public function setIsStreamerLive(bool $is_streamer_live): void
|
|
|
|
{
|
|
|
|
$this->is_streamer_live = $is_streamer_live;
|
|
|
|
}
|
|
|
|
|
2017-09-18 03:27:32 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-02-01 11:49:40 +00:00
|
|
|
public function getEnablePublicPage(): bool
|
2017-09-18 03:27:32 +00:00
|
|
|
{
|
2018-03-24 07:38:27 +00:00
|
|
|
return (bool)$this->enable_public_page && $this->isEnabled();
|
2017-09-18 03:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $enable_public_page
|
|
|
|
*/
|
|
|
|
public function setEnablePublicPage(bool $enable_public_page)
|
|
|
|
{
|
|
|
|
$this->enable_public_page = $enable_public_page;
|
|
|
|
}
|
|
|
|
|
2016-09-02 00:34:08 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return bool
|
2016-09-02 00:34:08 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getNeedsRestart(): bool
|
|
|
|
{
|
|
|
|
return $this->needs_restart;
|
|
|
|
}
|
2016-09-02 00:34:08 +00:00
|
|
|
|
2017-05-11 05:48:38 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @param bool $needs_restart
|
2017-05-11 05:48:38 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function setNeedsRestart(bool $needs_restart)
|
|
|
|
{
|
|
|
|
$this->needs_restart = $needs_restart;
|
|
|
|
}
|
2017-05-11 05:48:38 +00:00
|
|
|
|
2016-05-04 00:03:28 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @return bool
|
2016-05-04 00:03:28 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getHasStarted(): bool
|
|
|
|
{
|
|
|
|
return $this->has_started;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2016-11-17 03:15:34 +00:00
|
|
|
/**
|
2017-08-17 18:28:48 +00:00
|
|
|
* @param bool $has_started
|
2016-11-17 03:15:34 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function setHasStarted(bool $has_started)
|
|
|
|
{
|
|
|
|
$this->has_started = $has_started;
|
|
|
|
}
|
|
|
|
|
2018-08-18 23:01:03 +00:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getApiHistoryItems(): int
|
|
|
|
{
|
|
|
|
return $this->api_history_items ?? self::DEFAULT_API_HISTORY_ITEMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int|null $api_history_items
|
|
|
|
*/
|
|
|
|
public function setApiHistoryItems(?int $api_history_items): void
|
|
|
|
{
|
|
|
|
$this->api_history_items = $api_history_items;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getHistory(): Collection
|
|
|
|
{
|
|
|
|
return $this->history;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getMedia(): Collection
|
|
|
|
{
|
|
|
|
return $this->media;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getStreamers(): Collection
|
|
|
|
{
|
|
|
|
return $this->streamers;
|
|
|
|
}
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
|
|
|
* @return StationStreamer|null
|
|
|
|
*/
|
|
|
|
public function getCurrentStreamer(): ?StationStreamer
|
|
|
|
{
|
|
|
|
return $this->current_streamer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param StationStreamer|null $current_streamer
|
|
|
|
*/
|
|
|
|
public function setCurrentStreamer(?StationStreamer $current_streamer = null): void
|
|
|
|
{
|
|
|
|
$this->current_streamer = $current_streamer;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getPermissions(): Collection
|
|
|
|
{
|
|
|
|
return $this->permissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getPlaylists(): Collection
|
|
|
|
{
|
|
|
|
return $this->playlists;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getMounts(): Collection
|
|
|
|
{
|
|
|
|
return $this->mounts;
|
|
|
|
}
|
|
|
|
|
2018-09-09 18:23:03 +00:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getRemotes(): Collection
|
|
|
|
{
|
|
|
|
return $this->remotes;
|
|
|
|
}
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getWebhooks(): Collection
|
|
|
|
{
|
|
|
|
return $this->webhooks;
|
|
|
|
}
|
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
/**
|
|
|
|
* @param $name
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public static function getStationShortName($name): string
|
2015-01-02 08:16:54 +00:00
|
|
|
{
|
2017-01-24 00:17:50 +00:00
|
|
|
return strtolower(preg_replace("/[^A-Za-z0-9_]/", '', str_replace(' ', '_', trim($name))));
|
|
|
|
}
|
2016-09-06 06:25:41 +00:00
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the API version of the object/array.
|
|
|
|
*
|
2017-05-29 10:47:22 +00:00
|
|
|
* @param FrontendAbstract $fa
|
2018-09-22 11:52:43 +00:00
|
|
|
* @param AdapterProxy[] $remote_adapters
|
2018-10-04 23:12:12 +00:00
|
|
|
* @param UriInterface|null $base_url
|
2017-06-17 00:19:42 +00:00
|
|
|
* @return Api\Station
|
2017-01-24 00:17:50 +00:00
|
|
|
*/
|
2018-10-04 23:12:12 +00:00
|
|
|
public function api(FrontendAbstract $fa, array $remote_adapters = [], UriInterface $base_url = null): Api\Station
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-06-17 00:19:42 +00:00
|
|
|
$response = new Api\Station;
|
|
|
|
$response->id = (int)$this->id;
|
|
|
|
$response->name = (string)$this->name;
|
|
|
|
$response->shortcode = (string)$this->getShortName();
|
|
|
|
$response->description = (string)$this->description;
|
|
|
|
$response->frontend = (string)$this->frontend_type;
|
|
|
|
$response->backend = (string)$this->backend_type;
|
2017-10-08 22:27:47 +00:00
|
|
|
$response->is_public = (bool)$this->enable_public_page;
|
2018-10-04 23:12:12 +00:00
|
|
|
$response->listen_url = $fa->getStreamUrl($this, $base_url);
|
2017-06-17 00:19:42 +00:00
|
|
|
|
|
|
|
$mounts = [];
|
2018-09-22 11:52:43 +00:00
|
|
|
if ($fa::supportsMounts() && $this->mounts->count() > 0) {
|
2017-05-29 10:47:22 +00:00
|
|
|
foreach ($this->mounts as $mount) {
|
2018-10-04 23:12:12 +00:00
|
|
|
/** @var StationMount $mount */
|
|
|
|
$mounts[] = $mount->api($fa, $base_url);
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-17 00:19:42 +00:00
|
|
|
$response->mounts = $mounts;
|
2018-09-09 18:23:03 +00:00
|
|
|
|
|
|
|
$remotes = [];
|
2018-09-22 11:52:43 +00:00
|
|
|
foreach($remote_adapters as $ra_proxy) {
|
|
|
|
$remotes[] = $ra_proxy->getRemote()->api($ra_proxy->getAdapter());
|
2018-09-09 18:23:03 +00:00
|
|
|
}
|
|
|
|
$response->remotes = $remotes;
|
|
|
|
|
2017-06-17 00:19:42 +00:00
|
|
|
return $response;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
2018-08-04 22:05:14 +00:00
|
|
|
}
|