Bulk rename vars to camelCase (except controllers).
This commit is contained in:
parent
71560164b2
commit
0669d003c9
|
@ -159,7 +159,7 @@ return static function (RouteCollectorProxy $group) {
|
|||
}
|
||||
)->add(new Middleware\Permissions(GlobalPermissions::Settings));
|
||||
|
||||
$admin_api_endpoints = [
|
||||
$adminApiEndpoints = [
|
||||
[
|
||||
'custom_field',
|
||||
'custom_fields',
|
||||
|
@ -177,7 +177,7 @@ return static function (RouteCollectorProxy $group) {
|
|||
],
|
||||
];
|
||||
|
||||
foreach ($admin_api_endpoints as [$singular, $plural, $class, $permission]) {
|
||||
foreach ($adminApiEndpoints as [$singular, $plural, $class, $permission]) {
|
||||
$group->group(
|
||||
'',
|
||||
function (RouteCollectorProxy $group) use ($singular, $plural, $class) {
|
||||
|
|
|
@ -249,17 +249,17 @@ return [
|
|||
$loggingLevel = $environment->getLogLevel();
|
||||
|
||||
if ($environment->isCli() || $environment->isDocker()) {
|
||||
$log_stderr = new Monolog\Handler\StreamHandler('php://stderr', $loggingLevel, true);
|
||||
$logger->pushHandler($log_stderr);
|
||||
$logStderr = new Monolog\Handler\StreamHandler('php://stderr', $loggingLevel, true);
|
||||
$logger->pushHandler($logStderr);
|
||||
}
|
||||
|
||||
$log_file = new Monolog\Handler\RotatingFileHandler(
|
||||
$logFile = new Monolog\Handler\RotatingFileHandler(
|
||||
$environment->getTempDirectory() . '/app.log',
|
||||
5,
|
||||
$loggingLevel,
|
||||
true
|
||||
);
|
||||
$logger->pushHandler($log_file);
|
||||
$logger->pushHandler($logFile);
|
||||
|
||||
return $logger;
|
||||
},
|
||||
|
|
|
@ -35,12 +35,6 @@
|
|||
<exclude-pattern>src/Installer/EnvFiles/*.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
<rule ref="Squiz.NamingConventions.ValidVariableName">
|
||||
|
||||
</rule>
|
||||
-->
|
||||
|
||||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
|
||||
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
|
||||
</rule>
|
||||
|
|
52
src/Acl.php
52
src/Acl.php
|
@ -56,16 +56,16 @@ final class Acl
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $permission_name
|
||||
* @param bool $is_global
|
||||
* @param string $permissionName
|
||||
* @param bool $isGlobal
|
||||
*/
|
||||
public function isValidPermission(string $permission_name, bool $is_global): bool
|
||||
public function isValidPermission(string $permissionName, bool $isGlobal): bool
|
||||
{
|
||||
$permissions = $this->listPermissions();
|
||||
|
||||
return $is_global
|
||||
? isset($permissions['global'][$permission_name])
|
||||
: isset($permissions['station'][$permission_name]);
|
||||
return $isGlobal
|
||||
? isset($permissions['global'][$permissionName])
|
||||
: isset($permissions['station'][$permissionName]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,17 +157,17 @@ final class Acl
|
|||
/**
|
||||
* Check if a role (or array of roles) is allowed to perform an action (or array of actions).
|
||||
*
|
||||
* @param array|int $role_id
|
||||
* @param array<string|PermissionInterface>|string|PermissionInterface $action
|
||||
* @param int|Station|null $station_id
|
||||
* @param array|int $roleId
|
||||
* @param array<(string | PermissionInterface)>|string|PermissionInterface $action
|
||||
* @param int|Station|null $stationId
|
||||
*/
|
||||
public function roleAllowed(
|
||||
array|int $role_id,
|
||||
array|int $roleId,
|
||||
array|string|PermissionInterface $action,
|
||||
Station|int $station_id = null
|
||||
Station|int $stationId = null
|
||||
): bool {
|
||||
if ($station_id instanceof Station) {
|
||||
$station_id = $station_id->getId();
|
||||
if ($stationId instanceof Station) {
|
||||
$stationId = $stationId->getId();
|
||||
}
|
||||
|
||||
if ($action instanceof PermissionInterface) {
|
||||
|
@ -175,9 +175,9 @@ final class Acl
|
|||
}
|
||||
|
||||
// Iterate through an array of roles and return with the first "true" response, or "false" otherwise.
|
||||
if (is_array($role_id)) {
|
||||
foreach ($role_id as $r) {
|
||||
if ($this->roleAllowed($r, $action, $station_id)) {
|
||||
if (is_array($roleId)) {
|
||||
foreach ($roleId as $r) {
|
||||
if ($this->roleAllowed($r, $action, $stationId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ final class Acl
|
|||
// If multiple actions are supplied, treat the list as "x OR y OR z", returning if any action is allowed.
|
||||
if (is_array($action)) {
|
||||
foreach ($action as $a) {
|
||||
if ($this->roleAllowed($role_id, $a, $station_id)) {
|
||||
if ($this->roleAllowed($roleId, $a, $stationId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -196,45 +196,45 @@ final class Acl
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->actions[$role_id])) {
|
||||
$role_actions = (array)$this->actions[$role_id];
|
||||
if (!empty($this->actions[$roleId])) {
|
||||
$roleActions = (array)$this->actions[$roleId];
|
||||
|
||||
if (
|
||||
in_array(
|
||||
GlobalPermissions::All->value,
|
||||
(array)$role_actions['global'],
|
||||
(array)$roleActions['global'],
|
||||
true
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($station_id !== null) {
|
||||
if ($stationId !== null) {
|
||||
if (
|
||||
in_array(
|
||||
GlobalPermissions::Stations->value,
|
||||
(array)$role_actions['global'],
|
||||
(array)$roleActions['global'],
|
||||
true
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($role_actions['stations'][$station_id])) {
|
||||
if (!empty($roleActions['stations'][$stationId])) {
|
||||
if (
|
||||
in_array(
|
||||
StationPermissions::All->value,
|
||||
$role_actions['stations'][$station_id],
|
||||
$roleActions['stations'][$stationId],
|
||||
true
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($action, (array)$role_actions['stations'][$station_id], true);
|
||||
return in_array($action, (array)$roleActions['stations'][$stationId], true);
|
||||
}
|
||||
} else {
|
||||
return in_array($action, (array)$role_actions['global'], true);
|
||||
return in_array($action, (array)$roleActions['global'], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,9 +96,9 @@ final class AppFactory
|
|||
$containerBuilder->addDefinitions($diDefinitions);
|
||||
|
||||
// Check for services.php file and include it if one exists.
|
||||
$config_dir = $environment->getConfigDirectory();
|
||||
if (file_exists($config_dir . '/services.php')) {
|
||||
$containerBuilder->addDefinitions($config_dir . '/services.php');
|
||||
$configDir = $environment->getConfigDirectory();
|
||||
if (file_exists($configDir . '/services.php')) {
|
||||
$containerBuilder->addDefinitions($configDir . '/services.php');
|
||||
}
|
||||
|
||||
$di = $containerBuilder->build();
|
||||
|
|
26
src/Auth.php
26
src/Auth.php
|
@ -39,11 +39,11 @@ final class Auth
|
|||
*/
|
||||
public function authenticate(string $username, string $password): ?User
|
||||
{
|
||||
$user_auth = $this->userRepo->authenticate($username, $password);
|
||||
$userAuth = $this->userRepo->authenticate($username, $password);
|
||||
|
||||
if ($user_auth instanceof User) {
|
||||
$this->setUser($user_auth);
|
||||
return $user_auth;
|
||||
if ($userAuth instanceof User) {
|
||||
$this->setUser($userAuth);
|
||||
return $userAuth;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -52,13 +52,13 @@ final class Auth
|
|||
/**
|
||||
* Get the currently logged in user.
|
||||
*
|
||||
* @param bool $real_user_only
|
||||
* @param bool $realUserOnly
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getLoggedInUser(bool $real_user_only = false): ?User
|
||||
public function getLoggedInUser(bool $realUserOnly = false): ?User
|
||||
{
|
||||
if (!$real_user_only && $this->isMasqueraded()) {
|
||||
if (!$realUserOnly && $this->isMasqueraded()) {
|
||||
return $this->getMasquerade();
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ final class Auth
|
|||
if (!$this->session->has(self::SESSION_MASQUERADE_USER_ID_KEY)) {
|
||||
$this->masqueraded_user = false;
|
||||
} else {
|
||||
$mask_user_id = (int)$this->session->get(self::SESSION_MASQUERADE_USER_ID_KEY);
|
||||
if (0 !== $mask_user_id) {
|
||||
$user = $this->userRepo->getRepository()->find($mask_user_id);
|
||||
$maskUserId = (int)$this->session->get(self::SESSION_MASQUERADE_USER_ID_KEY);
|
||||
if (0 !== $maskUserId) {
|
||||
$user = $this->userRepo->getRepository()->find($maskUserId);
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
|
@ -136,14 +136,14 @@ final class Auth
|
|||
public function getUser(): ?User
|
||||
{
|
||||
if (null === $this->user) {
|
||||
$user_id = (int)$this->session->get(self::SESSION_USER_ID_KEY);
|
||||
$userId = (int)$this->session->get(self::SESSION_USER_ID_KEY);
|
||||
|
||||
if (0 === $user_id) {
|
||||
if (0 === $userId) {
|
||||
$this->user = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = $this->userRepo->getRepository()->find($user_id);
|
||||
$user = $this->userRepo->getRepository()->find($userId);
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
} else {
|
||||
|
|
|
@ -25,24 +25,24 @@ final class Application extends SymfonyApplication
|
|||
$input = new ArrayInput(array_merge(['command' => $command], $args));
|
||||
$input->setInteractive(false);
|
||||
|
||||
$temp_stream = fopen($outputFile, 'wb+');
|
||||
if (false === $temp_stream) {
|
||||
$tempStream = fopen($outputFile, 'wb+');
|
||||
if (false === $tempStream) {
|
||||
throw new RuntimeException(sprintf('Could not open output file: "%s"', $outputFile));
|
||||
}
|
||||
|
||||
$output = new StreamOutput($temp_stream);
|
||||
$output = new StreamOutput($tempStream);
|
||||
|
||||
$result_code = $this->find($command)->run($input, $output);
|
||||
$resultCode = $this->find($command)->run($input, $output);
|
||||
|
||||
rewind($temp_stream);
|
||||
$result_output = stream_get_contents($temp_stream);
|
||||
fclose($temp_stream);
|
||||
rewind($tempStream);
|
||||
$resultOutput = stream_get_contents($tempStream);
|
||||
fclose($tempStream);
|
||||
|
||||
$result_output = trim((string)$result_output);
|
||||
$resultOutput = trim((string)$resultOutput);
|
||||
|
||||
return [
|
||||
$result_code,
|
||||
$result_output,
|
||||
$resultCode,
|
||||
$resultOutput,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
$excludeMedia = (bool)$input->getOption('exclude-media');
|
||||
$storageLocationId = $input->getOption('storage-location-id');
|
||||
|
||||
$start_time = microtime(true);
|
||||
$startTime = microtime(true);
|
||||
|
||||
if (empty($path)) {
|
||||
$path = 'manual_backup_' . gmdate('Ymd_Hi') . '.zip';
|
||||
}
|
||||
|
||||
$file_ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$fileExt = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
|
||||
if (Path::isAbsolute($path)) {
|
||||
$tmpPath = $path;
|
||||
|
@ -64,7 +64,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
$tmpPath = $fsUtils->tempnam(
|
||||
sys_get_temp_dir(),
|
||||
'backup_',
|
||||
'.' . $file_ext
|
||||
'.' . $fileExt
|
||||
);
|
||||
|
||||
// Zip command cannot handle an existing file (even an empty one)
|
||||
|
@ -91,7 +91,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
}
|
||||
|
||||
$includeMedia = !$excludeMedia;
|
||||
$files_to_backup = [];
|
||||
$filesToBackup = [];
|
||||
|
||||
$io->title(__('AzuraCast Backup'));
|
||||
$io->writeln(__('Please wait while a backup is generated...'));
|
||||
|
@ -99,9 +99,9 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
// Create temp directories
|
||||
$io->section(__('Creating temporary directories...'));
|
||||
|
||||
$tmp_dir_mariadb = '/tmp/azuracast_backup_mariadb';
|
||||
$tmpDirMariadb = '/tmp/azuracast_backup_mariadb';
|
||||
try {
|
||||
$fsUtils->mkdir($tmp_dir_mariadb);
|
||||
$fsUtils->mkdir($tmpDirMariadb);
|
||||
} catch (Throwable $e) {
|
||||
$io->error($e->getMessage());
|
||||
return 1;
|
||||
|
@ -112,10 +112,10 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
// Back up MariaDB
|
||||
$io->section(__('Backing up MariaDB...'));
|
||||
|
||||
$path_db_dump = $tmp_dir_mariadb . '/db.sql';
|
||||
$this->dumpDatabase($io, $path_db_dump);
|
||||
$pathDbDump = $tmpDirMariadb . '/db.sql';
|
||||
$this->dumpDatabase($io, $pathDbDump);
|
||||
|
||||
$files_to_backup[] = $path_db_dump;
|
||||
$filesToBackup[] = $pathDbDump;
|
||||
$io->newLine();
|
||||
|
||||
// Include station media if specified.
|
||||
|
@ -130,7 +130,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
foreach ($stations as $station) {
|
||||
$mediaAdapter = $station->getMediaStorageLocation();
|
||||
if ($mediaAdapter->isLocal()) {
|
||||
$files_to_backup[] = $mediaAdapter->getPath();
|
||||
$filesToBackup[] = $mediaAdapter->getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,17 +139,17 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
$io->section(__('Creating backup archive...'));
|
||||
|
||||
// Strip leading slashes from backup paths.
|
||||
$files_to_backup = array_map(
|
||||
$filesToBackup = array_map(
|
||||
static function (string $val) {
|
||||
if (str_starts_with($val, '/')) {
|
||||
return substr($val, 1);
|
||||
}
|
||||
return $val;
|
||||
},
|
||||
$files_to_backup
|
||||
$filesToBackup
|
||||
);
|
||||
|
||||
switch ($file_ext) {
|
||||
switch ($fileExt) {
|
||||
case 'tzst':
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
|
@ -161,7 +161,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
'-cvf',
|
||||
$tmpPath,
|
||||
],
|
||||
$files_to_backup
|
||||
$filesToBackup
|
||||
),
|
||||
'/'
|
||||
);
|
||||
|
@ -177,7 +177,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
'zcvf',
|
||||
$tmpPath,
|
||||
],
|
||||
$files_to_backup
|
||||
$filesToBackup
|
||||
),
|
||||
'/'
|
||||
);
|
||||
|
@ -185,7 +185,7 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
|
||||
case 'zip':
|
||||
default:
|
||||
$dont_compress = ['.tar.gz', '.zip', '.jpg', '.mp3', '.ogg', '.flac', '.aac', '.wav'];
|
||||
$dontCompress = ['.tar.gz', '.zip', '.jpg', '.mp3', '.ogg', '.flac', '.aac', '.wav'];
|
||||
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
|
@ -194,10 +194,10 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
'zip',
|
||||
'-r',
|
||||
'-n',
|
||||
implode(':', $dont_compress),
|
||||
implode(':', $dontCompress),
|
||||
$tmpPath,
|
||||
],
|
||||
$files_to_backup
|
||||
$filesToBackup
|
||||
),
|
||||
'/'
|
||||
);
|
||||
|
@ -214,18 +214,18 @@ final class BackupCommand extends AbstractDatabaseCommand
|
|||
// Cleanup
|
||||
$io->section(__('Cleaning up temporary files...'));
|
||||
|
||||
$fsUtils->remove($tmp_dir_mariadb);
|
||||
$fsUtils->remove($tmpDirMariadb);
|
||||
|
||||
$io->newLine();
|
||||
|
||||
$end_time = microtime(true);
|
||||
$time_diff = $end_time - $start_time;
|
||||
$endTime = microtime(true);
|
||||
$timeDiff = $endTime - $startTime;
|
||||
|
||||
$io->success(
|
||||
[
|
||||
sprintf(
|
||||
__('Backup complete in %.2f seconds.'),
|
||||
$time_diff
|
||||
$timeDiff
|
||||
),
|
||||
]
|
||||
);
|
||||
|
|
|
@ -35,7 +35,7 @@ final class RestoreCommand extends AbstractDatabaseCommand
|
|||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$path = $input->getArgument('path');
|
||||
$start_time = microtime(true);
|
||||
$startTime = microtime(true);
|
||||
|
||||
$io->title('AzuraCast Restore');
|
||||
|
||||
|
@ -85,9 +85,9 @@ final class RestoreCommand extends AbstractDatabaseCommand
|
|||
// Extract tar.gz archive
|
||||
$io->section('Extracting backup file...');
|
||||
|
||||
$file_ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$fileExt = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
|
||||
switch ($file_ext) {
|
||||
switch ($fileExt) {
|
||||
case 'tzst':
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
|
@ -134,17 +134,17 @@ final class RestoreCommand extends AbstractDatabaseCommand
|
|||
// Handle DB dump
|
||||
$io->section('Importing database...');
|
||||
|
||||
$tmp_dir_mariadb = '/tmp/azuracast_backup_mariadb';
|
||||
$tmpDirMariadb = '/tmp/azuracast_backup_mariadb';
|
||||
|
||||
try {
|
||||
$path_db_dump = $tmp_dir_mariadb . '/db.sql';
|
||||
$this->restoreDatabaseDump($io, $path_db_dump);
|
||||
$pathDbDump = $tmpDirMariadb . '/db.sql';
|
||||
$this->restoreDatabaseDump($io, $pathDbDump);
|
||||
} catch (Exception $e) {
|
||||
$io->getErrorStyle()->error($e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
(new Filesystem())->remove($tmp_dir_mariadb);
|
||||
(new Filesystem())->remove($tmpDirMariadb);
|
||||
$io->newLine();
|
||||
|
||||
// Update from current version to latest.
|
||||
|
@ -152,12 +152,12 @@ final class RestoreCommand extends AbstractDatabaseCommand
|
|||
|
||||
$this->runCommand($output, 'azuracast:setup', ['--update' => true]);
|
||||
|
||||
$end_time = microtime(true);
|
||||
$time_diff = $end_time - $start_time;
|
||||
$endTime = microtime(true);
|
||||
$timeDiff = $endTime - $startTime;
|
||||
|
||||
$io->success(
|
||||
[
|
||||
'Restore complete in ' . round($time_diff, 3) . ' seconds.',
|
||||
'Restore complete in ' . round($timeDiff, 3) . ' seconds.',
|
||||
]
|
||||
);
|
||||
return 0;
|
||||
|
|
|
@ -11,14 +11,14 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
|
||||
abstract class CommandAbstract extends Command
|
||||
{
|
||||
protected function runCommand(OutputInterface $output, string $command_name, array $command_args = []): int
|
||||
protected function runCommand(OutputInterface $output, string $commandName, array $commandArgs = []): int
|
||||
{
|
||||
$command = $this->getApplication()?->find($command_name);
|
||||
$command = $this->getApplication()?->find($commandName);
|
||||
if (null === $command) {
|
||||
throw new RuntimeException(sprintf('Command %s not found.', $command_name));
|
||||
throw new RuntimeException(sprintf('Command %s not found.', $commandName));
|
||||
}
|
||||
|
||||
$input = new ArrayInput(['command' => $command_name] + $command_args);
|
||||
$input = new ArrayInput(['command' => $commandName] + $commandArgs);
|
||||
$input->setInteractive(false);
|
||||
|
||||
return $command->run($input, $output);
|
||||
|
|
|
@ -35,9 +35,9 @@ final class GenerateApiDocsCommand extends CommandAbstract
|
|||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$yaml = $this->generate()?->toYaml();
|
||||
$yaml_path = $this->environment->getBaseDirectory() . '/web/static/api/openapi.yml';
|
||||
$yamlPath = $this->environment->getBaseDirectory() . '/web/static/api/openapi.yml';
|
||||
|
||||
file_put_contents($yaml_path, $yaml);
|
||||
file_put_contents($yamlPath, $yaml);
|
||||
|
||||
$io->writeln('API documentation updated!');
|
||||
return 0;
|
||||
|
|
|
@ -61,8 +61,8 @@ final class GenerateCommand extends CommandAbstract
|
|||
$iterator = new RecursiveIteratorIterator($directory);
|
||||
$regex = new RegexIterator($iterator, '/^.+\.(phtml|php)$/i', RegexIterator::GET_MATCH);
|
||||
|
||||
foreach ($regex as $path_match) {
|
||||
$path = $path_match[0];
|
||||
foreach ($regex as $pathMatch) {
|
||||
$path = $pathMatch[0];
|
||||
$phpScanner->scanFile($path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ final class ListCommand extends CommandAbstract
|
|||
$rows = [];
|
||||
|
||||
$settings = $this->readSettings();
|
||||
foreach ($this->settingsRepo->toArray($settings) as $setting_key => $setting_value) {
|
||||
$value = print_r($setting_value, true);
|
||||
foreach ($this->settingsRepo->toArray($settings) as $settingKey => $settingValue) {
|
||||
$value = print_r($settingValue, true);
|
||||
$value = Utilities\Strings::truncateText($value, 600);
|
||||
|
||||
$rows[] = [$setting_key, $value];
|
||||
$rows[] = [$settingKey, $value];
|
||||
}
|
||||
|
||||
$io->table($headers, $rows);
|
||||
|
|
|
@ -126,7 +126,7 @@ final class SetupCommand extends CommandAbstract
|
|||
]
|
||||
);
|
||||
} else {
|
||||
$public_ip = $this->acCentral->getIp(false);
|
||||
$publicIp = $this->acCentral->getIp(false);
|
||||
|
||||
/** @noinspection HttpUrlsUsage */
|
||||
$io->success(
|
||||
|
@ -134,7 +134,7 @@ final class SetupCommand extends CommandAbstract
|
|||
__('AzuraCast installation complete!'),
|
||||
sprintf(
|
||||
__('Visit %s to complete setup.'),
|
||||
'http://' . $public_ip
|
||||
'http://' . $publicIp
|
||||
),
|
||||
]
|
||||
);
|
||||
|
|
|
@ -39,9 +39,9 @@ final class ResetPasswordCommand extends CommandAbstract
|
|||
->findOneBy(['email' => $email]);
|
||||
|
||||
if ($user instanceof User) {
|
||||
$temp_pw = Utilities\Strings::generatePassword(15);
|
||||
$tempPw = Utilities\Strings::generatePassword(15);
|
||||
|
||||
$user->setNewPassword($temp_pw);
|
||||
$user->setNewPassword($tempPw);
|
||||
$user->setTwoFactorSecret();
|
||||
|
||||
$this->em->persist($user);
|
||||
|
@ -50,7 +50,7 @@ final class ResetPasswordCommand extends CommandAbstract
|
|||
$io->text([
|
||||
'The account password has been reset. The new temporary password is:',
|
||||
'',
|
||||
' ' . $temp_pw,
|
||||
' ' . $tempPw,
|
||||
'',
|
||||
'Log in using this temporary password and set a new password using the web interface.',
|
||||
'',
|
||||
|
|
|
@ -47,9 +47,9 @@ final class SetAdministratorCommand extends CommandAbstract
|
|||
if ($user instanceof User) {
|
||||
$adminRole = $this->permsRepo->ensureSuperAdministratorRole();
|
||||
|
||||
$user_roles = $user->getRoles();
|
||||
if (!$user_roles->contains($adminRole)) {
|
||||
$user_roles->add($adminRole);
|
||||
$userRoles = $user->getRoles();
|
||||
if (!$userRoles->contains($adminRole)) {
|
||||
$userRoles->add($adminRole);
|
||||
}
|
||||
|
||||
$this->em->persist($user);
|
||||
|
|
|
@ -37,7 +37,7 @@ final class StationRequiresRestart implements EventSubscriber
|
|||
$em = $args->getObjectManager();
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
||||
$collections_to_check = [
|
||||
$collectionsToCheck = [
|
||||
[
|
||||
AuditLogOperations::Insert,
|
||||
$uow->getScheduledEntityInsertions(),
|
||||
|
@ -52,9 +52,9 @@ final class StationRequiresRestart implements EventSubscriber
|
|||
],
|
||||
];
|
||||
|
||||
$stations_to_restart = [];
|
||||
$stationsToRestart = [];
|
||||
|
||||
foreach ($collections_to_check as [$change_type, $collection]) {
|
||||
foreach ($collectionsToCheck as [$changeType, $collection]) {
|
||||
foreach ($collection as $entity) {
|
||||
if (
|
||||
($entity instanceof StationMount)
|
||||
|
@ -62,17 +62,17 @@ final class StationRequiresRestart implements EventSubscriber
|
|||
|| ($entity instanceof StationRemote && $entity->isEditable())
|
||||
|| ($entity instanceof StationPlaylist && $entity->getStation()->useManualAutoDJ())
|
||||
) {
|
||||
if (AuditLogOperations::Update === $change_type) {
|
||||
if (AuditLogOperations::Update === $changeType) {
|
||||
$changes = $uow->getEntityChangeSet($entity);
|
||||
|
||||
// Look for the @AuditIgnore annotation on a property.
|
||||
$class_reflection = new ReflectionObject($entity);
|
||||
foreach ($changes as $change_field => $changeset) {
|
||||
$ignoreAttr = $class_reflection->getProperty($change_field)->getAttributes(
|
||||
$classReflection = new ReflectionObject($entity);
|
||||
foreach ($changes as $changeField => $changeset) {
|
||||
$ignoreAttr = $classReflection->getProperty($changeField)->getAttributes(
|
||||
AuditIgnore::class
|
||||
);
|
||||
if (!empty($ignoreAttr)) {
|
||||
unset($changes[$change_field]);
|
||||
unset($changes[$changeField]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,18 +82,18 @@ final class StationRequiresRestart implements EventSubscriber
|
|||
}
|
||||
|
||||
$station = $entity->getStation();
|
||||
$stations_to_restart[$station->getId()] = $station;
|
||||
$stationsToRestart[$station->getId()] = $station;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($stations_to_restart) > 0) {
|
||||
foreach ($stations_to_restart as $station) {
|
||||
if (count($stationsToRestart) > 0) {
|
||||
foreach ($stationsToRestart as $station) {
|
||||
$station->setNeedsRestart(true);
|
||||
$em->persist($station);
|
||||
|
||||
$station_meta = $em->getClassMetadata(Station::class);
|
||||
$uow->recomputeSingleEntityChangeSet($station_meta, $station);
|
||||
$stationMeta = $em->getClassMetadata(Station::class);
|
||||
$uow->recomputeSingleEntityChangeSet($stationMeta, $station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,19 +67,19 @@ class Repository
|
|||
* Generate an array result of all records.
|
||||
*
|
||||
* @param bool $cached
|
||||
* @param string|null $order_by
|
||||
* @param string $order_dir
|
||||
* @param string|null $orderBy
|
||||
* @param string $orderDir
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function fetchArray(bool $cached = true, ?string $order_by = null, string $order_dir = 'ASC'): array
|
||||
public function fetchArray(bool $cached = true, ?string $orderBy = null, string $orderDir = 'ASC'): array
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder()
|
||||
->select('e')
|
||||
->from($this->entityClass, 'e');
|
||||
|
||||
if ($order_by) {
|
||||
$qb->orderBy('e.' . str_replace('e.', '', $order_by), $order_dir);
|
||||
if ($orderBy) {
|
||||
$qb->orderBy('e.' . str_replace('e.', '', $orderBy), $orderDir);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getArrayResult();
|
||||
|
@ -88,33 +88,33 @@ class Repository
|
|||
/**
|
||||
* Generic dropdown builder function (can be overridden for specialized use cases).
|
||||
*
|
||||
* @param bool|string $add_blank
|
||||
* @param bool|string $addBlank
|
||||
* @param Closure|NULL $display
|
||||
* @param string $pk
|
||||
* @param string $order_by
|
||||
* @param string $orderBy
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function fetchSelect(
|
||||
bool|string $add_blank = false,
|
||||
bool|string $addBlank = false,
|
||||
Closure $display = null,
|
||||
string $pk = 'id',
|
||||
string $order_by = 'name'
|
||||
string $orderBy = 'name'
|
||||
): array {
|
||||
$select = [];
|
||||
|
||||
// Specify custom text in the $add_blank parameter to override.
|
||||
if ($add_blank !== false) {
|
||||
$select[''] = ($add_blank === true) ? __('Select...') : $add_blank;
|
||||
if ($addBlank !== false) {
|
||||
$select[''] = ($addBlank === true) ? __('Select...') : $addBlank;
|
||||
}
|
||||
|
||||
// Build query for records.
|
||||
$qb = $this->em->createQueryBuilder()->from($this->entityClass, 'e');
|
||||
|
||||
if ($display === null) {
|
||||
$qb->select('e.' . $pk)->addSelect('e.name')->orderBy('e.' . $order_by, 'ASC');
|
||||
$qb->select('e.' . $pk)->addSelect('e.name')->orderBy('e.' . $orderBy, 'ASC');
|
||||
} else {
|
||||
$qb->select('e')->orderBy('e.' . $order_by, 'ASC');
|
||||
$qb->select('e')->orderBy('e.' . $orderBy, 'ASC');
|
||||
}
|
||||
|
||||
$results = $qb->getQuery()->getArrayResult();
|
||||
|
|
|
@ -51,10 +51,10 @@ class Analytics implements IdentifiableEntityInterface
|
|||
DateTimeInterface $moment,
|
||||
?Station $station = null,
|
||||
AnalyticsIntervals $type = AnalyticsIntervals::Daily,
|
||||
int $number_min = 0,
|
||||
int $number_max = 0,
|
||||
float $number_avg = 0,
|
||||
?int $number_unique = null
|
||||
int $numberMin = 0,
|
||||
int $numberMax = 0,
|
||||
float $numberAvg = 0,
|
||||
?int $numberUnique = null
|
||||
) {
|
||||
$utc = new DateTimeZone('UTC');
|
||||
|
||||
|
@ -63,10 +63,10 @@ class Analytics implements IdentifiableEntityInterface
|
|||
$this->station = $station;
|
||||
$this->type = $type;
|
||||
|
||||
$this->number_min = $number_min;
|
||||
$this->number_max = $number_max;
|
||||
$this->number_avg = (string)round($number_avg, 2);
|
||||
$this->number_unique = $number_unique;
|
||||
$this->number_min = $numberMin;
|
||||
$this->number_max = $numberMax;
|
||||
$this->number_avg = (string)round($numberAvg, 2);
|
||||
$this->number_unique = $numberUnique;
|
||||
}
|
||||
|
||||
public function getStation(): ?Station
|
||||
|
|
|
@ -54,14 +54,14 @@ final class Error
|
|||
public function __construct(
|
||||
int $code = 500,
|
||||
string $message = 'General Error',
|
||||
?string $formatted_message = null,
|
||||
array $extra_data = [],
|
||||
?string $formattedMessage = null,
|
||||
array $extraData = [],
|
||||
string $type = 'Error'
|
||||
) {
|
||||
$this->code = $code;
|
||||
$this->message = $message;
|
||||
$this->formatted_message = ($formatted_message ?? $message);
|
||||
$this->extra_data = $extra_data;
|
||||
$this->formatted_message = ($formattedMessage ?? $message);
|
||||
$this->extra_data = $extraData;
|
||||
$this->type = $type;
|
||||
$this->success = false;
|
||||
}
|
||||
|
|
|
@ -79,9 +79,9 @@ class NowPlaying implements ResolvableUrlInterface
|
|||
$this->playing_next->resolveUrls($base);
|
||||
}
|
||||
|
||||
foreach ($this->song_history as $history_obj) {
|
||||
if ($history_obj instanceof ResolvableUrlInterface) {
|
||||
$history_obj->resolveUrls($base);
|
||||
foreach ($this->song_history as $historyObj) {
|
||||
if ($historyObj instanceof ResolvableUrlInterface) {
|
||||
$historyObj->resolveUrls($base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ final class StationPlaylistImportResult extends Status
|
|||
public function __construct(
|
||||
bool $success = true,
|
||||
string $message = 'Changes saved successfully.',
|
||||
?string $formatted_message = null,
|
||||
array $import_results = [],
|
||||
?string $formattedMessage = null,
|
||||
array $importResults = [],
|
||||
) {
|
||||
parent::__construct($success, $message, $formatted_message);
|
||||
parent::__construct($success, $message, $formattedMessage);
|
||||
|
||||
$this->import_results = $import_results;
|
||||
$this->import_results = $importResults;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@ final class StationServiceStatus
|
|||
public bool $station_needs_restart;
|
||||
|
||||
public function __construct(
|
||||
bool $backend_running,
|
||||
bool $frontend_running,
|
||||
bool $station_has_started,
|
||||
bool $station_needs_restart
|
||||
bool $backendRunning,
|
||||
bool $frontendRunning,
|
||||
bool $stationHasStarted,
|
||||
bool $stationNeedsRestart
|
||||
) {
|
||||
$this->backend_running = $backend_running;
|
||||
$this->frontend_running = $frontend_running;
|
||||
$this->station_has_started = $station_has_started;
|
||||
$this->station_needs_restart = $station_needs_restart;
|
||||
$this->backend_running = $backendRunning;
|
||||
$this->frontend_running = $frontendRunning;
|
||||
$this->station_has_started = $stationHasStarted;
|
||||
$this->station_needs_restart = $stationNeedsRestart;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ class Status
|
|||
public function __construct(
|
||||
bool $success = true,
|
||||
string $message = 'Changes saved successfully.',
|
||||
?string $formatted_message = null
|
||||
?string $formattedMessage = null
|
||||
) {
|
||||
$this->success = $success;
|
||||
$this->message = $message;
|
||||
$this->formatted_message = $formatted_message ?? $message;
|
||||
$this->formatted_message = $formattedMessage ?? $message;
|
||||
}
|
||||
|
||||
public static function success(): self
|
||||
|
|
|
@ -109,23 +109,23 @@ final class SongApiGenerator
|
|||
/**
|
||||
* Return all custom fields, either with a null value or with the custom value assigned to the given Media ID.
|
||||
*
|
||||
* @param int|null $media_id
|
||||
* @param int|null $mediaId
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function getCustomFields(?int $media_id = null): array
|
||||
private function getCustomFields(?int $mediaId = null): array
|
||||
{
|
||||
$fields = $this->customFieldRepo->getFieldIds();
|
||||
|
||||
$mediaFields = [];
|
||||
if ($media_id !== null) {
|
||||
if ($mediaId !== null) {
|
||||
$mediaFieldsRaw = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT smcf.field_id, smcf.value
|
||||
FROM App\Entity\StationMediaCustomField smcf
|
||||
WHERE smcf.media_id = :media_id
|
||||
DQL
|
||||
)->setParameter('media_id', $media_id)
|
||||
)->setParameter('media_id', $mediaId)
|
||||
->getArrayResult();
|
||||
|
||||
foreach ($mediaFieldsRaw as $row) {
|
||||
|
|
|
@ -66,11 +66,11 @@ class CustomField implements Stringable, IdentifiableEntityInterface
|
|||
: self::generateShortName($this->name);
|
||||
}
|
||||
|
||||
public function setShortName(string $short_name): void
|
||||
public function setShortName(string $shortName): void
|
||||
{
|
||||
$short_name = trim($short_name);
|
||||
if (!empty($short_name)) {
|
||||
$this->short_name = $this->truncateString($short_name, 100);
|
||||
$shortName = trim($shortName);
|
||||
if (!empty($shortName)) {
|
||||
$this->short_name = $this->truncateString($shortName, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ class CustomField implements Stringable, IdentifiableEntityInterface
|
|||
return !empty($this->auto_assign);
|
||||
}
|
||||
|
||||
public function setAutoAssign(?string $auto_assign): void
|
||||
public function setAutoAssign(?string $autoAssign): void
|
||||
{
|
||||
$this->auto_assign = $auto_assign;
|
||||
$this->auto_assign = $autoAssign;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
|
|
@ -18,37 +18,37 @@ final class AnalyticsFixture extends AbstractFixture implements DependentFixture
|
|||
{
|
||||
$stations = $manager->getRepository(Station::class)->findAll();
|
||||
|
||||
$midnight_utc = CarbonImmutable::now('UTC')->setTime(0, 0);
|
||||
$midnightUtc = CarbonImmutable::now('UTC')->setTime(0, 0);
|
||||
|
||||
for ($i = 1; $i <= 14; $i++) {
|
||||
$day = $midnight_utc->subDays($i);
|
||||
$day = $midnightUtc->subDays($i);
|
||||
|
||||
$day_min = 0;
|
||||
$day_max = 0;
|
||||
$day_listeners = 0;
|
||||
$day_unique = 0;
|
||||
$dayMin = 0;
|
||||
$dayMax = 0;
|
||||
$dayListeners = 0;
|
||||
$dayUnique = 0;
|
||||
|
||||
foreach ($stations as $station) {
|
||||
/** @var Station $station */
|
||||
$station_listeners = random_int(10, 50);
|
||||
$station_min = random_int(1, $station_listeners);
|
||||
$station_max = random_int($station_listeners, 150);
|
||||
$stationListeners = random_int(10, 50);
|
||||
$stationMin = random_int(1, $stationListeners);
|
||||
$stationMax = random_int($stationListeners, 150);
|
||||
|
||||
$station_unique = random_int(1, 250);
|
||||
$stationUnique = random_int(1, 250);
|
||||
|
||||
$day_min = min($day_min, $station_min);
|
||||
$day_max = max($day_max, $station_max);
|
||||
$day_listeners += $station_listeners;
|
||||
$day_unique += $station_unique;
|
||||
$dayMin = min($dayMin, $stationMin);
|
||||
$dayMax = max($dayMax, $stationMax);
|
||||
$dayListeners += $stationListeners;
|
||||
$dayUnique += $stationUnique;
|
||||
|
||||
$stationPoint = new Analytics(
|
||||
$day,
|
||||
$station,
|
||||
AnalyticsIntervals::Daily,
|
||||
$station_min,
|
||||
$station_max,
|
||||
$station_listeners,
|
||||
$station_unique
|
||||
$stationMin,
|
||||
$stationMax,
|
||||
$stationListeners,
|
||||
$stationUnique
|
||||
);
|
||||
$manager->persist($stationPoint);
|
||||
}
|
||||
|
@ -57,10 +57,10 @@ final class AnalyticsFixture extends AbstractFixture implements DependentFixture
|
|||
$day,
|
||||
null,
|
||||
AnalyticsIntervals::Daily,
|
||||
$day_min,
|
||||
$day_max,
|
||||
$day_listeners,
|
||||
$day_unique
|
||||
$dayMin,
|
||||
$dayMax,
|
||||
$dayListeners,
|
||||
$dayUnique
|
||||
);
|
||||
$manager->persist($totalPoint);
|
||||
}
|
||||
|
|
|
@ -15,28 +15,28 @@ final class ApiKeyFixture extends AbstractFixture implements DependentFixtureInt
|
|||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$demo_api_key = getenv('INIT_DEMO_API_KEY');
|
||||
$demoApiKey = getenv('INIT_DEMO_API_KEY');
|
||||
|
||||
if (!empty($demo_api_key) && $this->hasReference('demo_user')) {
|
||||
/** @var User $demo_user */
|
||||
$demo_user = $this->getReference('demo_user');
|
||||
if (!empty($demoApiKey) && $this->hasReference('demo_user')) {
|
||||
/** @var User $demoUser */
|
||||
$demoUser = $this->getReference('demo_user');
|
||||
|
||||
$api_key = new ApiKey($demo_user, SplitToken::fromKeyString($demo_api_key));
|
||||
$api_key->setComment('Demo User');
|
||||
$apiKey = new ApiKey($demoUser, SplitToken::fromKeyString($demoApiKey));
|
||||
$apiKey->setComment('Demo User');
|
||||
|
||||
$manager->persist($api_key);
|
||||
$manager->persist($apiKey);
|
||||
}
|
||||
|
||||
$admin_api_key = getenv('INIT_ADMIN_API_KEY');
|
||||
$adminApiKey = getenv('INIT_ADMIN_API_KEY');
|
||||
|
||||
if (!empty($admin_api_key) && $this->hasReference('admin_user')) {
|
||||
/** @var User $admin_user */
|
||||
$admin_user = $this->getReference('admin_user');
|
||||
if (!empty($adminApiKey) && $this->hasReference('admin_user')) {
|
||||
/** @var User $adminUser */
|
||||
$adminUser = $this->getReference('admin_user');
|
||||
|
||||
$api_key = new ApiKey($admin_user, SplitToken::fromKeyString($admin_api_key));
|
||||
$api_key->setComment('Administrator');
|
||||
$apiKey = new ApiKey($adminUser, SplitToken::fromKeyString($adminApiKey));
|
||||
$apiKey->setComment('Administrator');
|
||||
|
||||
$manager->persist($api_key);
|
||||
$manager->persist($apiKey);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
|
|
@ -12,17 +12,17 @@ final class RoleFixture extends AbstractFixture
|
|||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$admin_role = new Role();
|
||||
$admin_role->setName('Super Administrator');
|
||||
$adminRole = new Role();
|
||||
$adminRole->setName('Super Administrator');
|
||||
|
||||
$demo_role = new Role();
|
||||
$demo_role->setName('Demo Account');
|
||||
$demoRole = new Role();
|
||||
$demoRole->setName('Demo Account');
|
||||
|
||||
$manager->persist($admin_role);
|
||||
$manager->persist($demo_role);
|
||||
$manager->persist($adminRole);
|
||||
$manager->persist($demoRole);
|
||||
$manager->flush();
|
||||
|
||||
$this->addReference('admin_role', $admin_role);
|
||||
$this->addReference('demo_role', $demo_role);
|
||||
$this->addReference('admin_role', $adminRole);
|
||||
$this->addReference('demo_role', $demoRole);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ final class RolePermissionFixture extends AbstractFixture implements DependentFi
|
|||
],
|
||||
];
|
||||
|
||||
foreach ($permissions as $role_reference => $perm_names) {
|
||||
foreach ($permissions as $roleReference => $permNames) {
|
||||
/** @var Role $role */
|
||||
$role = $this->getReference($role_reference);
|
||||
$role = $this->getReference($roleReference);
|
||||
|
||||
foreach ($perm_names as $perm_name) {
|
||||
$rp = new RolePermission($role, $perm_name[1], $perm_name[0]);
|
||||
foreach ($permNames as $permName) {
|
||||
$rp = new RolePermission($role, $permName[1], $permName[0]);
|
||||
$manager->persist($rp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,15 +17,15 @@ final class StationMountFixture extends AbstractFixture implements DependentFixt
|
|||
/** @var Station $station */
|
||||
$station = $this->getReference('station');
|
||||
|
||||
$mount_radio = new StationMount($station);
|
||||
$mount_radio->setName('/radio.mp3');
|
||||
$mount_radio->setIsDefault(true);
|
||||
$manager->persist($mount_radio);
|
||||
$mountRadio = new StationMount($station);
|
||||
$mountRadio->setName('/radio.mp3');
|
||||
$mountRadio->setIsDefault(true);
|
||||
$manager->persist($mountRadio);
|
||||
|
||||
$mount_mobile = new StationMount($station);
|
||||
$mount_mobile->setName('/mobile.mp3');
|
||||
$mount_mobile->setAutodjBitrate(64);
|
||||
$manager->persist($mount_mobile);
|
||||
$mountMobile = new StationMount($station);
|
||||
$mountMobile->setName('/mobile.mp3');
|
||||
$mountMobile->setAutodjBitrate(64);
|
||||
$manager->persist($mountMobile);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
|
|
@ -15,41 +15,41 @@ final class UserFixture extends AbstractFixture implements DependentFixtureInter
|
|||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$admin_email = getenv('INIT_ADMIN_EMAIL');
|
||||
$admin_password = getenv('INIT_ADMIN_PASSWORD');
|
||||
$adminEmail = getenv('INIT_ADMIN_EMAIL');
|
||||
$adminPassword = getenv('INIT_ADMIN_PASSWORD');
|
||||
|
||||
if (!empty($admin_email) && !empty($admin_password)) {
|
||||
$demo_user = new User();
|
||||
$demo_user->setEmail('demo@azuracast.com');
|
||||
$demo_user->setNewPassword('demo');
|
||||
$demo_user->setName('AzuraCast Demo User');
|
||||
if (!empty($adminEmail) && !empty($adminPassword)) {
|
||||
$demoUser = new User();
|
||||
$demoUser->setEmail('demo@azuracast.com');
|
||||
$demoUser->setNewPassword('demo');
|
||||
$demoUser->setName('AzuraCast Demo User');
|
||||
|
||||
/** @var Role $demoRole */
|
||||
$demoRole = $this->getReference('demo_role');
|
||||
$demo_user->getRoles()->add($demoRole);
|
||||
$demoUser->getRoles()->add($demoRole);
|
||||
|
||||
$manager->persist($demo_user);
|
||||
$manager->persist($demoUser);
|
||||
|
||||
$this->addReference('demo_user', $demo_user);
|
||||
$this->addReference('demo_user', $demoUser);
|
||||
|
||||
$admin_user = new User();
|
||||
$admin_user->setEmail($admin_email);
|
||||
$admin_user->setName('System Administrator');
|
||||
$admin_user->setNewPassword($admin_password);
|
||||
$admin_user->setTheme(SupportedThemes::Browser);
|
||||
$adminUser = new User();
|
||||
$adminUser->setEmail($adminEmail);
|
||||
$adminUser->setName('System Administrator');
|
||||
$adminUser->setNewPassword($adminPassword);
|
||||
$adminUser->setTheme(SupportedThemes::Browser);
|
||||
|
||||
/** @var Role $adminRole */
|
||||
$adminRole = $this->getReference('admin_role');
|
||||
$admin_user->getRoles()->add($adminRole);
|
||||
$adminUser->getRoles()->add($adminRole);
|
||||
|
||||
$admin_2fa_secret = getenv('INIT_ADMIN_2FA_SECRET');
|
||||
if (!empty($admin_2fa_secret)) {
|
||||
$admin_user->setTwoFactorSecret($admin_2fa_secret);
|
||||
$admin2faSecret = getenv('INIT_ADMIN_2FA_SECRET');
|
||||
if (!empty($admin2faSecret)) {
|
||||
$adminUser->setTwoFactorSecret($admin2faSecret);
|
||||
}
|
||||
|
||||
$manager->persist($admin_user);
|
||||
$manager->persist($adminUser);
|
||||
|
||||
$this->addReference('admin_user', $admin_user);
|
||||
$this->addReference('admin_user', $adminUser);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
|
|
|
@ -135,9 +135,9 @@ class Listener implements
|
|||
return $this->hls_stream_id;
|
||||
}
|
||||
|
||||
public function setHlsStream(?StationHlsStream $hls_stream): void
|
||||
public function setHlsStream(?StationHlsStream $hlsStream): void
|
||||
{
|
||||
$this->hls_stream = $hls_stream;
|
||||
$this->hls_stream = $hlsStream;
|
||||
}
|
||||
|
||||
public function getListenerUid(): int
|
||||
|
@ -175,9 +175,9 @@ class Listener implements
|
|||
return $this->timestamp_end;
|
||||
}
|
||||
|
||||
public function setTimestampEnd(int $timestamp_end): void
|
||||
public function setTimestampEnd(int $timestampEnd): void
|
||||
{
|
||||
$this->timestamp_end = $timestamp_end;
|
||||
$this->timestamp_end = $timestampEnd;
|
||||
}
|
||||
|
||||
public function getConnectedSeconds(): int
|
||||
|
|
|
@ -22,11 +22,11 @@ final class Version20170412210654 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAllAssociative(
|
||||
$allStations = $this->connection->fetchAllAssociative(
|
||||
"SELECT * FROM station WHERE frontend_type='shoutcast2'"
|
||||
);
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
foreach ($allStations as $station) {
|
||||
$this->connection->insert('station_mounts', [
|
||||
'station_id' => $station['id'],
|
||||
'name' => '/radio.mp3',
|
||||
|
|
|
@ -22,7 +22,7 @@ final class Version20170829030442 extends AbstractMigration
|
|||
|
||||
private function changeCharset(string $charset, string $collate): void
|
||||
{
|
||||
$db_name = $this->connection->getDatabase() ?? 'azuracast';
|
||||
$dbName = $this->connection->getDatabase() ?? 'azuracast';
|
||||
|
||||
$sqlLines = [
|
||||
'ALTER TABLE listener CHANGE listener_user_agent listener_user_agent VARCHAR(255) NOT NULL',
|
||||
|
@ -31,7 +31,7 @@ final class Version20170829030442 extends AbstractMigration
|
|||
'ALTER TABLE station_mounts CHANGE relay_url relay_url VARCHAR(255) DEFAULT NULL, CHANGE authhash authhash VARCHAR(255) DEFAULT NULL',
|
||||
'ALTER TABLE users CHANGE auth_password auth_password VARCHAR(255) DEFAULT NULL',
|
||||
'ALTER TABLE app_migrations CHANGE version version VARCHAR(191) NOT NULL',
|
||||
'ALTER DATABASE ' . $this->connection->quoteIdentifier($db_name) . ' CHARACTER SET = ' . $charset . ' COLLATE = ' . $collate,
|
||||
'ALTER DATABASE ' . $this->connection->quoteIdentifier($dbName) . ' CHARACTER SET = ' . $charset . ' COLLATE = ' . $collate,
|
||||
'ALTER TABLE `song_history` DROP FOREIGN KEY FK_2AD16164A0BDB2F3',
|
||||
'ALTER TABLE `station_media` DROP FOREIGN KEY FK_32AADE3AA0BDB2F3',
|
||||
'ALTER TABLE `analytics` CONVERT TO CHARACTER SET ' . $charset . ' COLLATE ' . $collate,
|
||||
|
|
|
@ -22,7 +22,7 @@ final class Version20180826043500 extends AbstractMigration
|
|||
|
||||
private function changeCharset(string $collate): void
|
||||
{
|
||||
$db_name = $this->connection->getDatabase() ?? 'azuracast';
|
||||
$dbName = $this->connection->getDatabase() ?? 'azuracast';
|
||||
|
||||
$tables = [
|
||||
'analytics',
|
||||
|
@ -52,7 +52,7 @@ final class Version20180826043500 extends AbstractMigration
|
|||
|
||||
$sqlLines = [
|
||||
'ALTER DATABASE ' . $this->connection->quoteIdentifier(
|
||||
$db_name
|
||||
$dbName
|
||||
) . ' CHARACTER SET = utf8mb4 COLLATE = ' . $collate,
|
||||
'ALTER TABLE `song_history` DROP FOREIGN KEY FK_2AD16164A0BDB2F3',
|
||||
'ALTER TABLE `station_media` DROP FOREIGN KEY FK_32AADE3AA0BDB2F3',
|
||||
|
@ -61,10 +61,10 @@ final class Version20180826043500 extends AbstractMigration
|
|||
$this->addSql($sql);
|
||||
}
|
||||
|
||||
foreach ($tables as $table_name) {
|
||||
foreach ($tables as $tableName) {
|
||||
$this->addSql(
|
||||
'ALTER TABLE ' . $this->connection->quoteIdentifier(
|
||||
$table_name
|
||||
$tableName
|
||||
) . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE ' . $collate
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@ final class Version20181016144143 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$shuffled_playlists = $this->connection->fetchAllAssociative(
|
||||
$shuffledPlaylists = $this->connection->fetchAllAssociative(
|
||||
'SELECT sp.* FROM station_playlists AS sp WHERE sp.playback_order = :order',
|
||||
[
|
||||
'order' => 'shuffle',
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($shuffled_playlists as $playlist) {
|
||||
$all_media = $this->connection->fetchAllAssociative(
|
||||
foreach ($shuffledPlaylists as $playlist) {
|
||||
$allMedia = $this->connection->fetchAllAssociative(
|
||||
'SELECT spm.* FROM station_playlist_media AS spm WHERE spm.playlist_id = :playlist_id ORDER BY RAND()',
|
||||
[
|
||||
'playlist_id' => $playlist['id'],
|
||||
|
@ -36,7 +36,7 @@ final class Version20181016144143 extends AbstractMigration
|
|||
);
|
||||
|
||||
$weight = 1;
|
||||
foreach ($all_media as $row) {
|
||||
foreach ($allMedia as $row) {
|
||||
$this->connection->update('station_playlist_media', [
|
||||
'weight' => $weight,
|
||||
], [
|
||||
|
|
|
@ -19,10 +19,10 @@ final class Version20181202180617 extends AbstractMigration
|
|||
foreach ($this->connection->fetchAllAssociative('SELECT s.* FROM station AS s') as $station) {
|
||||
$this->write('Migrating album art for station "' . $station['name'] . '"...');
|
||||
|
||||
$base_dir = $station['radio_base_dir'];
|
||||
$art_dir = $base_dir . '/album_art';
|
||||
if (!mkdir($art_dir) && !is_dir($art_dir)) {
|
||||
throw new RuntimeException(sprintf('Directory "%s" was not created', $art_dir));
|
||||
$baseDir = $station['radio_base_dir'];
|
||||
$artDir = $baseDir . '/album_art';
|
||||
if (!mkdir($artDir) && !is_dir($artDir)) {
|
||||
throw new RuntimeException(sprintf('Directory "%s" was not created', $artDir));
|
||||
}
|
||||
|
||||
$stmt = $this->connection->executeQuery(
|
||||
|
@ -34,9 +34,9 @@ final class Version20181202180617 extends AbstractMigration
|
|||
[ParameterType::INTEGER]
|
||||
);
|
||||
|
||||
while ($art_row = $stmt->fetchAssociative()) {
|
||||
$art_path = $art_dir . '/' . $art_row['unique_id'] . '.jpg';
|
||||
file_put_contents($art_path, $art_row['art']);
|
||||
while ($artRow = $stmt->fetchAssociative()) {
|
||||
$artPath = $artDir . '/' . $artRow['unique_id'] . '.jpg';
|
||||
file_put_contents($artPath, $artRow['art']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,20 @@ final class Version20190429025906 extends AbstractMigration
|
|||
$playlists = $this->connection->fetchAllAssociative('SELECT sp.* FROM station_playlists AS sp');
|
||||
|
||||
foreach ($playlists as $playlist) {
|
||||
$backend_options = [];
|
||||
$backendOptions = [];
|
||||
|
||||
if ($playlist['interrupt_other_songs']) {
|
||||
$backend_options[] = 'interrupt';
|
||||
$backendOptions[] = 'interrupt';
|
||||
}
|
||||
if ($playlist['loop_playlist_once']) {
|
||||
$backend_options[] = 'loop_once';
|
||||
$backendOptions[] = 'loop_once';
|
||||
}
|
||||
if ($playlist['play_single_track']) {
|
||||
$backend_options[] = 'single_track';
|
||||
$backendOptions[] = 'single_track';
|
||||
}
|
||||
|
||||
$this->connection->update('station_playlists', [
|
||||
'backend_options' => implode(',', $backend_options),
|
||||
'backend_options' => implode(',', $backendOptions),
|
||||
], [
|
||||
'id' => $playlist['id'],
|
||||
]);
|
||||
|
|
|
@ -27,41 +27,41 @@ final class Version20190513163051 extends AbstractMigration
|
|||
public function postup(Schema $schema): void
|
||||
{
|
||||
// Use the system setting for "global timezone" to set the station timezones.
|
||||
$global_tz = $this->connection->fetchOne('SELECT setting_value FROM settings WHERE setting_key="timezone"');
|
||||
$globalTz = $this->connection->fetchOne('SELECT setting_value FROM settings WHERE setting_key="timezone"');
|
||||
|
||||
if (!empty($global_tz)) {
|
||||
$global_tz = json_decode($global_tz, true, 512, JSON_THROW_ON_ERROR);
|
||||
if (!empty($globalTz)) {
|
||||
$globalTz = json_decode($globalTz, true, 512, JSON_THROW_ON_ERROR);
|
||||
} else {
|
||||
$global_tz = 'UTC';
|
||||
$globalTz = 'UTC';
|
||||
}
|
||||
|
||||
// Set all stations' timezones to this value.
|
||||
$this->connection->update('station', [
|
||||
'timezone' => $global_tz,
|
||||
'timezone' => $globalTz,
|
||||
], [1 => 1]);
|
||||
|
||||
// Calculate the offset of any currently scheduled playlists.
|
||||
if ('UTC' !== $global_tz) {
|
||||
$system_tz = new DateTimeZone('UTC');
|
||||
$system_dt = new DateTime('now', $system_tz);
|
||||
$system_offset = $system_tz->getOffset($system_dt);
|
||||
if ('UTC' !== $globalTz) {
|
||||
$systemTz = new DateTimeZone('UTC');
|
||||
$systemDt = new DateTime('now', $systemTz);
|
||||
$systemOffset = $systemTz->getOffset($systemDt);
|
||||
|
||||
$app_tz = new DateTimeZone($global_tz);
|
||||
$app_dt = new DateTime('now', $app_tz);
|
||||
$app_offset = $app_tz->getOffset($app_dt);
|
||||
$appTz = new DateTimeZone($globalTz);
|
||||
$appDt = new DateTime('now', $appTz);
|
||||
$appOffset = $appTz->getOffset($appDt);
|
||||
|
||||
$offset = $system_offset - $app_offset;
|
||||
$offset_hours = (int)floor($offset / 3600);
|
||||
$offset = $systemOffset - $appOffset;
|
||||
$offsetHours = (int)floor($offset / 3600);
|
||||
|
||||
if (0 !== $offset_hours) {
|
||||
if (0 !== $offsetHours) {
|
||||
$playlists = $this->connection->fetchAllAssociative(
|
||||
'SELECT sp.* FROM station_playlists AS sp WHERE sp.type = "scheduled"'
|
||||
);
|
||||
|
||||
foreach ($playlists as $playlist) {
|
||||
$this->connection->update('station_playlists', [
|
||||
'schedule_start_time' => $this->applyOffset($playlist['schedule_start_time'], $offset_hours),
|
||||
'schedule_end_time' => $this->applyOffset($playlist['schedule_end_time'], $offset_hours),
|
||||
'schedule_start_time' => $this->applyOffset($playlist['schedule_start_time'], $offsetHours),
|
||||
'schedule_end_time' => $this->applyOffset($playlist['schedule_end_time'], $offsetHours),
|
||||
], [
|
||||
'id' => $playlist['id'],
|
||||
]);
|
||||
|
@ -71,18 +71,18 @@ final class Version20190513163051 extends AbstractMigration
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $time_code
|
||||
* @param int $offset_hours
|
||||
* @param mixed $timeCode
|
||||
* @param int $offsetHours
|
||||
*
|
||||
* @return int
|
||||
* @noinspection SummerTimeUnsafeTimeManipulationInspection
|
||||
*/
|
||||
private function applyOffset(mixed $time_code, int $offset_hours): int
|
||||
private function applyOffset(mixed $timeCode, int $offsetHours): int
|
||||
{
|
||||
$hours = (int)floor($time_code / 100);
|
||||
$mins = $time_code % 100;
|
||||
$hours = (int)floor($timeCode / 100);
|
||||
$mins = $timeCode % 100;
|
||||
|
||||
$hours += $offset_hours;
|
||||
$hours += $offsetHours;
|
||||
|
||||
$hours %= 24;
|
||||
if ($hours < 0) {
|
||||
|
|
|
@ -28,13 +28,13 @@ final class Version20200129010322 extends AbstractMigration
|
|||
$accounts = [];
|
||||
|
||||
foreach ($streamers as $row) {
|
||||
$station_id = $row['station_id'];
|
||||
$stationId = $row['station_id'];
|
||||
$username = $row['streamer_username'];
|
||||
|
||||
if (isset($accounts[$station_id][$username])) {
|
||||
if (isset($accounts[$stationId][$username])) {
|
||||
$this->connection->delete('station_streamers', ['id' => $row['id']]);
|
||||
} else {
|
||||
$accounts[$station_id][$username] = $username;
|
||||
$accounts[$stationId][$username] = $username;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,9 +149,9 @@ class Podcast implements Interfaces\IdentifiableEntityInterface
|
|||
return $this->art_updated_at;
|
||||
}
|
||||
|
||||
public function setArtUpdatedAt(int $art_updated_at): self
|
||||
public function setArtUpdatedAt(int $artUpdatedAt): self
|
||||
{
|
||||
$this->art_updated_at = $art_updated_at;
|
||||
$this->art_updated_at = $artUpdatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -150,9 +150,9 @@ class PodcastEpisode implements IdentifiableEntityInterface
|
|||
return $this->art_updated_at;
|
||||
}
|
||||
|
||||
public function setArtUpdatedAt(int $art_updated_at): self
|
||||
public function setArtUpdatedAt(int $artUpdatedAt): self
|
||||
{
|
||||
$this->art_updated_at = $art_updated_at;
|
||||
$this->art_updated_at = $artUpdatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -156,9 +156,9 @@ class PodcastMedia implements IdentifiableEntityInterface
|
|||
return $this->art_updated_at;
|
||||
}
|
||||
|
||||
public function setArtUpdatedAt(int $art_updated_at): self
|
||||
public function setArtUpdatedAt(int $artUpdatedAt): self
|
||||
{
|
||||
$this->art_updated_at = $art_updated_at;
|
||||
$this->art_updated_at = $artUpdatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -56,9 +56,9 @@ class Relay implements IdentifiableEntityInterface
|
|||
#[ORM\OneToMany(mappedBy: 'relay', targetEntity: StationRemote::class)]
|
||||
protected Collection $remotes;
|
||||
|
||||
public function __construct(string $base_url)
|
||||
public function __construct(string $baseUrl)
|
||||
{
|
||||
$this->base_url = $this->truncateString($base_url);
|
||||
$this->base_url = $this->truncateString($baseUrl);
|
||||
|
||||
$this->created_at = time();
|
||||
$this->updated_at = time();
|
||||
|
@ -92,9 +92,9 @@ class Relay implements IdentifiableEntityInterface
|
|||
return $this->is_visible_on_public_pages;
|
||||
}
|
||||
|
||||
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
|
||||
public function setIsVisibleOnPublicPages(bool $isVisibleOnPublicPages): void
|
||||
{
|
||||
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
|
||||
$this->is_visible_on_public_pages = $isVisibleOnPublicPages;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): int
|
||||
|
@ -102,9 +102,9 @@ class Relay implements IdentifiableEntityInterface
|
|||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt(int $created_at): void
|
||||
public function setCreatedAt(int $createdAt): void
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
$this->created_at = $createdAt;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): int
|
||||
|
@ -112,9 +112,9 @@ class Relay implements IdentifiableEntityInterface
|
|||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(int $updated_at): void
|
||||
public function setUpdatedAt(int $updatedAt): void
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
$this->updated_at = $updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,7 +70,7 @@ final class CustomFieldRepository extends Repository
|
|||
*/
|
||||
public function getCustomFields(StationMedia $media): array
|
||||
{
|
||||
$metadata_raw = $this->em->createQuery(
|
||||
$metadataRaw = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT cf.short_name, e.value
|
||||
FROM App\Entity\StationMediaCustomField e JOIN e.field cf
|
||||
|
@ -80,7 +80,7 @@ final class CustomFieldRepository extends Repository
|
|||
->getArrayResult();
|
||||
|
||||
$result = [];
|
||||
foreach ($metadata_raw as $row) {
|
||||
foreach ($metadataRaw as $row) {
|
||||
$result[$row['short_name']] = $row['value'];
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,9 @@ final class CustomFieldRepository extends Repository
|
|||
* Set the custom metadata for a specified station based on a provided key-value array.
|
||||
*
|
||||
* @param StationMedia $media
|
||||
* @param array $custom_fields
|
||||
* @param array $customFields
|
||||
*/
|
||||
public function setCustomFields(StationMedia $media, array $custom_fields): void
|
||||
public function setCustomFields(StationMedia $media, array $customFields): void
|
||||
{
|
||||
$this->em->createQuery(
|
||||
<<<'DQL'
|
||||
|
@ -102,14 +102,14 @@ final class CustomFieldRepository extends Repository
|
|||
)->setParameter('media_id', $media->getId())
|
||||
->execute();
|
||||
|
||||
foreach ($custom_fields as $field_id => $field_value) {
|
||||
$field = is_numeric($field_id)
|
||||
? $this->em->find(CustomField::class, $field_id)
|
||||
: $this->em->getRepository(CustomField::class)->findOneBy(['short_name' => $field_id]);
|
||||
foreach ($customFields as $fieldId => $fieldValue) {
|
||||
$field = is_numeric($fieldId)
|
||||
? $this->em->find(CustomField::class, $fieldId)
|
||||
: $this->em->getRepository(CustomField::class)->findOneBy(['short_name' => $fieldId]);
|
||||
|
||||
if ($field instanceof CustomField) {
|
||||
$record = new StationMediaCustomField($media, $field);
|
||||
$record->setValue($field_value);
|
||||
$record->setValue($fieldValue);
|
||||
$this->em->persist($record);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ final class RolePermissionRepository extends Repository
|
|||
*/
|
||||
public function getActionsForRole(Role $role): array
|
||||
{
|
||||
$role_has_action = $this->em->createQuery(
|
||||
$roleHasAction = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT e
|
||||
FROM App\Entity\RolePermission e
|
||||
|
@ -33,7 +33,7 @@ final class RolePermissionRepository extends Repository
|
|||
->getArrayResult();
|
||||
|
||||
$result = [];
|
||||
foreach ($role_has_action as $row) {
|
||||
foreach ($roleHasAction as $row) {
|
||||
if ($row['station_id']) {
|
||||
$result['actions_' . $row['station_id']][] = $row['action_name'];
|
||||
} else {
|
||||
|
|
|
@ -283,9 +283,9 @@ final class StationMediaRepository extends Repository
|
|||
|
||||
$metadata = $media->toMetadata();
|
||||
|
||||
$art_path = StationMedia::getArtPath($media->getUniqueId());
|
||||
if ($fs->fileExists($art_path)) {
|
||||
$metadata->setArtwork($fs->read($art_path));
|
||||
$artPath = StationMedia::getArtPath($media->getUniqueId());
|
||||
if ($fs->fileExists($artPath)) {
|
||||
$metadata->setArtwork($fs->read($artPath));
|
||||
}
|
||||
|
||||
// Write tags to the Media file.
|
||||
|
|
|
@ -85,7 +85,7 @@ final class StationPlaylistMediaRepository extends Repository
|
|||
public function getHighestSongWeight(StationPlaylist $playlist): int
|
||||
{
|
||||
try {
|
||||
$highest_weight = $this->em->createQuery(
|
||||
$highestWeight = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT MAX(e.weight)
|
||||
FROM App\Entity\StationPlaylistMedia e
|
||||
|
@ -94,10 +94,10 @@ final class StationPlaylistMediaRepository extends Repository
|
|||
)->setParameter('playlist_id', $playlist->getId())
|
||||
->getSingleScalarResult();
|
||||
} catch (NoResultException) {
|
||||
$highest_weight = 1;
|
||||
$highestWeight = 1;
|
||||
}
|
||||
|
||||
return (int)$highest_weight;
|
||||
return (int)$highestWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +147,7 @@ final class StationPlaylistMediaRepository extends Repository
|
|||
*/
|
||||
public function setMediaOrder(StationPlaylist $playlist, array $mapping): void
|
||||
{
|
||||
$update_query = $this->em->createQuery(
|
||||
$updateQuery = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
UPDATE App\Entity\StationPlaylistMedia e
|
||||
SET e.weight = :weight
|
||||
|
@ -157,9 +157,9 @@ final class StationPlaylistMediaRepository extends Repository
|
|||
)->setParameter('playlist_id', $playlist->getId());
|
||||
|
||||
$this->em->wrapInTransaction(
|
||||
function () use ($update_query, $mapping): void {
|
||||
function () use ($updateQuery, $mapping): void {
|
||||
foreach ($mapping as $id => $weight) {
|
||||
$update_query->setParameter('id', $id)
|
||||
$updateQuery->setParameter('id', $id)
|
||||
->setParameter('weight', $weight)
|
||||
->execute();
|
||||
}
|
||||
|
|
|
@ -63,16 +63,16 @@ final class StationRepository extends Repository
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function fetchSelect(
|
||||
bool|string $add_blank = false,
|
||||
bool|string $addBlank = false,
|
||||
Closure $display = null,
|
||||
string $pk = 'id',
|
||||
string $order_by = 'name'
|
||||
string $orderBy = 'name'
|
||||
): array {
|
||||
$select = [];
|
||||
|
||||
// Specify custom text in the $add_blank parameter to override.
|
||||
if ($add_blank !== false) {
|
||||
$select[''] = ($add_blank === true) ? 'Select...' : $add_blank;
|
||||
if ($addBlank !== false) {
|
||||
$select[''] = ($addBlank === true) ? 'Select...' : $addBlank;
|
||||
}
|
||||
|
||||
// Build query for records.
|
||||
|
|
|
@ -79,17 +79,17 @@ final class StationRequestRepository extends AbstractStationBasedRepository
|
|||
}
|
||||
|
||||
// Verify that Track ID exists with station.
|
||||
$media_item = $this->mediaRepo->requireByUniqueId($trackId, $station);
|
||||
$mediaItem = $this->mediaRepo->requireByUniqueId($trackId, $station);
|
||||
|
||||
if (!$media_item->isRequestable()) {
|
||||
if (!$mediaItem->isRequestable()) {
|
||||
throw new Exception(__('The song ID you specified cannot be requested for this station.'));
|
||||
}
|
||||
|
||||
// Check if the song is already enqueued as a request.
|
||||
$this->checkPendingRequest($media_item, $station);
|
||||
$this->checkPendingRequest($mediaItem, $station);
|
||||
|
||||
// Check the most recent song history.
|
||||
$this->checkRecentPlay($media_item, $station);
|
||||
$this->checkRecentPlay($mediaItem, $station);
|
||||
|
||||
if (!$isAuthenticated) {
|
||||
// Check for any request (on any station) within the last $threshold_seconds.
|
||||
|
@ -119,7 +119,7 @@ final class StationRequestRepository extends AbstractStationBasedRepository
|
|||
}
|
||||
|
||||
// Save request locally.
|
||||
$record = new StationRequest($station, $media_item, $ip);
|
||||
$record = new StationRequest($station, $mediaItem, $ip);
|
||||
$this->em->persist($record);
|
||||
$this->em->flush();
|
||||
|
||||
|
@ -136,10 +136,10 @@ final class StationRequestRepository extends AbstractStationBasedRepository
|
|||
*/
|
||||
public function checkPendingRequest(StationMedia $media, Station $station): bool
|
||||
{
|
||||
$pending_request_threshold = time() - (60 * 10);
|
||||
$pendingRequestThreshold = time() - (60 * 10);
|
||||
|
||||
try {
|
||||
$pending_request = $this->em->createQuery(
|
||||
$pendingRequest = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT sr.timestamp
|
||||
FROM App\Entity\StationRequest sr
|
||||
|
@ -150,14 +150,14 @@ final class StationRequestRepository extends AbstractStationBasedRepository
|
|||
DQL
|
||||
)->setParameter('track_id', $media->getId())
|
||||
->setParameter('station_id', $station->getId())
|
||||
->setParameter('threshold', $pending_request_threshold)
|
||||
->setParameter('threshold', $pendingRequestThreshold)
|
||||
->setMaxResults(1)
|
||||
->getSingleScalarResult();
|
||||
} catch (PhpException) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($pending_request > 0) {
|
||||
if ($pendingRequest > 0) {
|
||||
throw new Exception(__('Duplicate request: this song was already requested and will play soon.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ class RolePermission implements
|
|||
public function __construct(
|
||||
Role $role,
|
||||
Station $station = null,
|
||||
string|PermissionInterface|null $action_name = null
|
||||
string|PermissionInterface|null $actionName = null
|
||||
) {
|
||||
$this->role = $role;
|
||||
$this->station = $station;
|
||||
|
||||
if (null !== $action_name) {
|
||||
$this->setActionName($action_name);
|
||||
if (null !== $actionName) {
|
||||
$this->setActionName($actionName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,13 +75,13 @@ class RolePermission implements
|
|||
return $this->action_name;
|
||||
}
|
||||
|
||||
public function setActionName(string|PermissionInterface $action_name): void
|
||||
public function setActionName(string|PermissionInterface $actionName): void
|
||||
{
|
||||
if ($action_name instanceof PermissionInterface) {
|
||||
$action_name = $action_name->getValue();
|
||||
if ($actionName instanceof PermissionInterface) {
|
||||
$actionName = $actionName->getValue();
|
||||
}
|
||||
|
||||
$this->action_name = $action_name;
|
||||
$this->action_name = $actionName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -620,9 +620,9 @@ class Settings implements Stringable
|
|||
return Strings::nonEmptyOrNull($this->backup_format);
|
||||
}
|
||||
|
||||
public function setBackupFormat(?string $backup_format): void
|
||||
public function setBackupFormat(?string $backupFormat): void
|
||||
{
|
||||
$this->backup_format = Strings::nonEmptyOrNull($backup_format);
|
||||
$this->backup_format = Strings::nonEmptyOrNull($backupFormat);
|
||||
}
|
||||
|
||||
#[
|
||||
|
@ -710,9 +710,9 @@ class Settings implements Stringable
|
|||
return $this->sync_disabled;
|
||||
}
|
||||
|
||||
public function setSyncDisabled(bool $sync_disabled): void
|
||||
public function setSyncDisabled(bool $syncDisabled): void
|
||||
{
|
||||
$this->sync_disabled = $sync_disabled;
|
||||
$this->sync_disabled = $syncDisabled;
|
||||
}
|
||||
|
||||
#[
|
||||
|
@ -1002,9 +1002,9 @@ class Settings implements Stringable
|
|||
return $this->acme_email;
|
||||
}
|
||||
|
||||
public function setAcmeEmail(?string $acme_email): void
|
||||
public function setAcmeEmail(?string $acmeEmail): void
|
||||
{
|
||||
$this->acme_email = $acme_email;
|
||||
$this->acme_email = $acmeEmail;
|
||||
}
|
||||
|
||||
#[
|
||||
|
@ -1019,12 +1019,12 @@ class Settings implements Stringable
|
|||
return Strings::nonEmptyOrNull($this->acme_domains);
|
||||
}
|
||||
|
||||
public function setAcmeDomains(?string $acme_domains): void
|
||||
public function setAcmeDomains(?string $acmeDomains): void
|
||||
{
|
||||
$acme_domains = Strings::nonEmptyOrNull($acme_domains);
|
||||
$acmeDomains = Strings::nonEmptyOrNull($acmeDomains);
|
||||
|
||||
if (null !== $acme_domains) {
|
||||
$acme_domains = implode(
|
||||
if (null !== $acmeDomains) {
|
||||
$acmeDomains = implode(
|
||||
', ',
|
||||
array_map(
|
||||
static function ($str) {
|
||||
|
@ -1033,12 +1033,12 @@ class Settings implements Stringable
|
|||
$str = str_replace(['http://', 'https://'], '', $str);
|
||||
return $str;
|
||||
},
|
||||
explode(',', $acme_domains)
|
||||
explode(',', $acmeDomains)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->acme_domains = $acme_domains;
|
||||
$this->acme_domains = $acmeDomains;
|
||||
}
|
||||
|
||||
#[
|
||||
|
|
|
@ -47,7 +47,7 @@ class Song implements SongInterface
|
|||
);
|
||||
}
|
||||
|
||||
$song_text = mb_substr($songText, 0, 150, 'UTF-8');
|
||||
$songText = mb_substr($songText, 0, 150, 'UTF-8');
|
||||
|
||||
// Strip out characters that are likely to not be properly translated or relayed through the radio.
|
||||
$removeChars = [
|
||||
|
@ -60,10 +60,10 @@ class Song implements SongInterface
|
|||
"\r",
|
||||
];
|
||||
|
||||
$song_text = str_replace($removeChars, '', $song_text);
|
||||
$songText = str_replace($removeChars, '', $songText);
|
||||
|
||||
$hash_base = mb_strtolower($song_text, 'UTF-8');
|
||||
return md5($hash_base);
|
||||
$hashBase = mb_strtolower($songText, 'UTF-8');
|
||||
return md5($hashBase);
|
||||
}
|
||||
|
||||
public static function createFromApiSong(Api\Song $apiSong): self
|
||||
|
|
|
@ -159,9 +159,9 @@ class SongHistory implements
|
|||
return $this->timestamp_start;
|
||||
}
|
||||
|
||||
public function setTimestampStart(int $timestamp_start): void
|
||||
public function setTimestampStart(int $timestampStart): void
|
||||
{
|
||||
$this->timestamp_start = $timestamp_start;
|
||||
$this->timestamp_start = $timestampStart;
|
||||
}
|
||||
|
||||
public function getDuration(): ?int
|
||||
|
@ -179,9 +179,9 @@ class SongHistory implements
|
|||
return $this->listeners_start;
|
||||
}
|
||||
|
||||
public function setListenersStart(?int $listeners_start): void
|
||||
public function setListenersStart(?int $listenersStart): void
|
||||
{
|
||||
$this->listeners_start = $listeners_start;
|
||||
$this->listeners_start = $listenersStart;
|
||||
}
|
||||
|
||||
public function getTimestampEnd(): int
|
||||
|
@ -189,12 +189,12 @@ class SongHistory implements
|
|||
return $this->timestamp_end;
|
||||
}
|
||||
|
||||
public function setTimestampEnd(int $timestamp_end): void
|
||||
public function setTimestampEnd(int $timestampEnd): void
|
||||
{
|
||||
$this->timestamp_end = $timestamp_end;
|
||||
$this->timestamp_end = $timestampEnd;
|
||||
|
||||
if (!$this->duration) {
|
||||
$this->duration = $timestamp_end - $this->timestamp_start;
|
||||
$this->duration = $timestampEnd - $this->timestamp_start;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,9 +208,9 @@ class SongHistory implements
|
|||
return $this->listeners_end;
|
||||
}
|
||||
|
||||
public function setListenersEnd(?int $listeners_end): void
|
||||
public function setListenersEnd(?int $listenersEnd): void
|
||||
{
|
||||
$this->listeners_end = $listeners_end;
|
||||
$this->listeners_end = $listenersEnd;
|
||||
}
|
||||
|
||||
public function getUniqueListeners(): ?int
|
||||
|
@ -218,9 +218,9 @@ class SongHistory implements
|
|||
return $this->unique_listeners;
|
||||
}
|
||||
|
||||
public function setUniqueListeners(?int $unique_listeners): void
|
||||
public function setUniqueListeners(?int $uniqueListeners): void
|
||||
{
|
||||
$this->unique_listeners = $unique_listeners;
|
||||
$this->unique_listeners = $uniqueListeners;
|
||||
}
|
||||
|
||||
public function getListeners(): int
|
||||
|
@ -233,9 +233,9 @@ class SongHistory implements
|
|||
return $this->delta_total;
|
||||
}
|
||||
|
||||
public function setDeltaTotal(int $delta_total): void
|
||||
public function setDeltaTotal(int $deltaTotal): void
|
||||
{
|
||||
$this->delta_total = $this->truncateSmallInt($delta_total);
|
||||
$this->delta_total = $this->truncateSmallInt($deltaTotal);
|
||||
}
|
||||
|
||||
public function getDeltaPositive(): int
|
||||
|
@ -243,9 +243,9 @@ class SongHistory implements
|
|||
return $this->delta_positive;
|
||||
}
|
||||
|
||||
public function setDeltaPositive(int $delta_positive): void
|
||||
public function setDeltaPositive(int $deltaPositive): void
|
||||
{
|
||||
$this->delta_positive = $this->truncateSmallInt($delta_positive);
|
||||
$this->delta_positive = $this->truncateSmallInt($deltaPositive);
|
||||
}
|
||||
|
||||
public function getDeltaNegative(): int
|
||||
|
@ -253,9 +253,9 @@ class SongHistory implements
|
|||
return $this->delta_negative;
|
||||
}
|
||||
|
||||
public function setDeltaNegative(int $delta_negative): void
|
||||
public function setDeltaNegative(int $deltaNegative): void
|
||||
{
|
||||
$this->delta_negative = $this->truncateSmallInt($delta_negative);
|
||||
$this->delta_negative = $this->truncateSmallInt($deltaNegative);
|
||||
}
|
||||
|
||||
public function getDeltaPoints(): mixed
|
||||
|
@ -263,16 +263,16 @@ class SongHistory implements
|
|||
return $this->delta_points;
|
||||
}
|
||||
|
||||
public function addDeltaPoint(int $delta_point): void
|
||||
public function addDeltaPoint(int $deltaPoint): void
|
||||
{
|
||||
$delta_points = (array)$this->delta_points;
|
||||
$deltaPoints = (array)$this->delta_points;
|
||||
|
||||
if (0 === count($delta_points)) {
|
||||
$this->setListenersStart($delta_point);
|
||||
if (0 === count($deltaPoints)) {
|
||||
$this->setListenersStart($deltaPoint);
|
||||
}
|
||||
|
||||
$delta_points[] = $delta_point;
|
||||
$this->delta_points = $delta_points;
|
||||
$deltaPoints[] = $deltaPoint;
|
||||
$this->delta_points = $deltaPoints;
|
||||
}
|
||||
|
||||
public function setListenersFromLastSong(?SongHistory $lastSong): void
|
||||
|
@ -293,9 +293,9 @@ class SongHistory implements
|
|||
return $this->is_visible;
|
||||
}
|
||||
|
||||
public function setIsVisible(bool $is_visible): void
|
||||
public function setIsVisible(bool $isVisible): void
|
||||
{
|
||||
$this->is_visible = $is_visible;
|
||||
$this->is_visible = $isVisible;
|
||||
}
|
||||
|
||||
public function updateVisibility(): void
|
||||
|
|
|
@ -448,9 +448,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
$this->short_name = $shortName;
|
||||
}
|
||||
|
||||
public function setIsEnabled(bool $is_enabled): void
|
||||
public function setIsEnabled(bool $isEnabled): void
|
||||
{
|
||||
$this->is_enabled = $is_enabled;
|
||||
$this->is_enabled = $isEnabled;
|
||||
}
|
||||
|
||||
public function getFrontendType(): FrontendAdapters
|
||||
|
@ -458,9 +458,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->frontend_type;
|
||||
}
|
||||
|
||||
public function setFrontendType(FrontendAdapters $frontend_type): void
|
||||
public function setFrontendType(FrontendAdapters $frontendType): void
|
||||
{
|
||||
$this->frontend_type = $frontend_type;
|
||||
$this->frontend_type = $frontendType;
|
||||
}
|
||||
|
||||
public function getFrontendConfig(): StationFrontendConfiguration
|
||||
|
@ -469,16 +469,16 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
}
|
||||
|
||||
public function setFrontendConfig(
|
||||
StationFrontendConfiguration|array $frontend_config,
|
||||
bool $force_overwrite = false
|
||||
StationFrontendConfiguration|array $frontendConfig,
|
||||
bool $forceOverwrite = false
|
||||
): void {
|
||||
if (is_array($frontend_config)) {
|
||||
$frontend_config = new StationFrontendConfiguration(
|
||||
$force_overwrite ? $frontend_config : array_merge((array)$this->frontend_config, $frontend_config)
|
||||
if (is_array($frontendConfig)) {
|
||||
$frontendConfig = new StationFrontendConfiguration(
|
||||
$forceOverwrite ? $frontendConfig : array_merge((array)$this->frontend_config, $frontendConfig)
|
||||
);
|
||||
}
|
||||
|
||||
$config = $frontend_config->toArray();
|
||||
$config = $frontendConfig->toArray();
|
||||
if ($this->frontend_config !== $config) {
|
||||
$this->setNeedsRestart(true);
|
||||
}
|
||||
|
@ -490,9 +490,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->backend_type;
|
||||
}
|
||||
|
||||
public function setBackendType(BackendAdapters $backend_type): void
|
||||
public function setBackendType(BackendAdapters $backendType): void
|
||||
{
|
||||
$this->backend_type = $backend_type;
|
||||
$this->backend_type = $backendType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -522,16 +522,16 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
}
|
||||
|
||||
public function setBackendConfig(
|
||||
StationBackendConfiguration|array $backend_config,
|
||||
bool $force_overwrite = false
|
||||
StationBackendConfiguration|array $backendConfig,
|
||||
bool $forceOverwrite = false
|
||||
): void {
|
||||
if (is_array($backend_config)) {
|
||||
$backend_config = new StationBackendConfiguration(
|
||||
$force_overwrite ? $backend_config : array_merge((array)$this->backend_config, $backend_config)
|
||||
if (is_array($backendConfig)) {
|
||||
$backendConfig = new StationBackendConfiguration(
|
||||
$forceOverwrite ? $backendConfig : array_merge((array)$this->backend_config, $backendConfig)
|
||||
);
|
||||
}
|
||||
|
||||
$config = $backend_config->toArray();
|
||||
$config = $backendConfig->toArray();
|
||||
|
||||
if ($this->backend_config !== $config) {
|
||||
$this->setNeedsRestart(true);
|
||||
|
@ -556,11 +556,11 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
/**
|
||||
* Authenticate the supplied adapter API key.
|
||||
*
|
||||
* @param string $api_key
|
||||
* @param string $apiKey
|
||||
*/
|
||||
public function validateAdapterApiKey(string $api_key): bool
|
||||
public function validateAdapterApiKey(string $apiKey): bool
|
||||
{
|
||||
return hash_equals($api_key, $this->adapter_api_key ?? '');
|
||||
return hash_equals($apiKey, $this->adapter_api_key ?? '');
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
|
@ -707,9 +707,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_requests;
|
||||
}
|
||||
|
||||
public function setEnableRequests(bool $enable_requests): void
|
||||
public function setEnableRequests(bool $enableRequests): void
|
||||
{
|
||||
$this->enable_requests = $enable_requests;
|
||||
$this->enable_requests = $enableRequests;
|
||||
}
|
||||
|
||||
public function getRequestDelay(): ?int
|
||||
|
@ -717,9 +717,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->request_delay;
|
||||
}
|
||||
|
||||
public function setRequestDelay(int $request_delay = null): void
|
||||
public function setRequestDelay(int $requestDelay = null): void
|
||||
{
|
||||
$this->request_delay = $request_delay;
|
||||
$this->request_delay = $requestDelay;
|
||||
}
|
||||
|
||||
public function getRequestThreshold(): ?int
|
||||
|
@ -727,9 +727,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->request_threshold;
|
||||
}
|
||||
|
||||
public function setRequestThreshold(int $request_threshold = null): void
|
||||
public function setRequestThreshold(int $requestThreshold = null): void
|
||||
{
|
||||
$this->request_threshold = $request_threshold;
|
||||
$this->request_threshold = $requestThreshold;
|
||||
}
|
||||
|
||||
public function getDisconnectDeactivateStreamer(): ?int
|
||||
|
@ -737,9 +737,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->disconnect_deactivate_streamer;
|
||||
}
|
||||
|
||||
public function setDisconnectDeactivateStreamer(?int $disconnect_deactivate_streamer): void
|
||||
public function setDisconnectDeactivateStreamer(?int $disconnectDeactivateStreamer): void
|
||||
{
|
||||
$this->disconnect_deactivate_streamer = $disconnect_deactivate_streamer;
|
||||
$this->disconnect_deactivate_streamer = $disconnectDeactivateStreamer;
|
||||
}
|
||||
|
||||
public function getEnableStreamers(): bool
|
||||
|
@ -747,13 +747,13 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_streamers;
|
||||
}
|
||||
|
||||
public function setEnableStreamers(bool $enable_streamers): void
|
||||
public function setEnableStreamers(bool $enableStreamers): void
|
||||
{
|
||||
if ($this->enable_streamers !== $enable_streamers) {
|
||||
if ($this->enable_streamers !== $enableStreamers) {
|
||||
$this->setNeedsRestart(true);
|
||||
}
|
||||
|
||||
$this->enable_streamers = $enable_streamers;
|
||||
$this->enable_streamers = $enableStreamers;
|
||||
}
|
||||
|
||||
public function getIsStreamerLive(): bool
|
||||
|
@ -761,9 +761,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->is_streamer_live;
|
||||
}
|
||||
|
||||
public function setIsStreamerLive(bool $is_streamer_live): void
|
||||
public function setIsStreamerLive(bool $isStreamerLive): void
|
||||
{
|
||||
$this->is_streamer_live = $is_streamer_live;
|
||||
$this->is_streamer_live = $isStreamerLive;
|
||||
}
|
||||
|
||||
public function getEnablePublicPage(): bool
|
||||
|
@ -771,9 +771,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_public_page && $this->getIsEnabled();
|
||||
}
|
||||
|
||||
public function setEnablePublicPage(bool $enable_public_page): void
|
||||
public function setEnablePublicPage(bool $enablePublicPage): void
|
||||
{
|
||||
$this->enable_public_page = $enable_public_page;
|
||||
$this->enable_public_page = $enablePublicPage;
|
||||
}
|
||||
|
||||
public function getEnableOnDemand(): bool
|
||||
|
@ -781,9 +781,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_on_demand;
|
||||
}
|
||||
|
||||
public function setEnableOnDemand(bool $enable_on_demand): void
|
||||
public function setEnableOnDemand(bool $enableOnDemand): void
|
||||
{
|
||||
$this->enable_on_demand = $enable_on_demand;
|
||||
$this->enable_on_demand = $enableOnDemand;
|
||||
}
|
||||
|
||||
public function getEnableOnDemandDownload(): bool
|
||||
|
@ -791,9 +791,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_on_demand_download;
|
||||
}
|
||||
|
||||
public function setEnableOnDemandDownload(bool $enable_on_demand_download): void
|
||||
public function setEnableOnDemandDownload(bool $enableOnDemandDownload): void
|
||||
{
|
||||
$this->enable_on_demand_download = $enable_on_demand_download;
|
||||
$this->enable_on_demand_download = $enableOnDemandDownload;
|
||||
}
|
||||
|
||||
public function getEnableHls(): bool
|
||||
|
@ -801,9 +801,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->enable_hls;
|
||||
}
|
||||
|
||||
public function setEnableHls(bool $enable_hls): void
|
||||
public function setEnableHls(bool $enableHls): void
|
||||
{
|
||||
$this->enable_hls = $enable_hls;
|
||||
$this->enable_hls = $enableHls;
|
||||
}
|
||||
|
||||
public function getIsEnabled(): bool
|
||||
|
@ -816,9 +816,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->needs_restart;
|
||||
}
|
||||
|
||||
public function setNeedsRestart(bool $needs_restart): void
|
||||
public function setNeedsRestart(bool $needsRestart): void
|
||||
{
|
||||
$this->needs_restart = $needs_restart;
|
||||
$this->needs_restart = $needsRestart;
|
||||
}
|
||||
|
||||
public function getHasStarted(): bool
|
||||
|
@ -826,9 +826,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->has_started;
|
||||
}
|
||||
|
||||
public function setHasStarted(bool $has_started): void
|
||||
public function setHasStarted(bool $hasStarted): void
|
||||
{
|
||||
$this->has_started = $has_started;
|
||||
$this->has_started = $hasStarted;
|
||||
}
|
||||
|
||||
public function getApiHistoryItems(): int
|
||||
|
@ -836,9 +836,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->api_history_items ?? 5;
|
||||
}
|
||||
|
||||
public function setApiHistoryItems(int $api_history_items): void
|
||||
public function setApiHistoryItems(int $apiHistoryItems): void
|
||||
{
|
||||
$this->api_history_items = $api_history_items;
|
||||
$this->api_history_items = $apiHistoryItems;
|
||||
}
|
||||
|
||||
public function getTimezone(): string
|
||||
|
@ -899,10 +899,10 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->current_streamer;
|
||||
}
|
||||
|
||||
public function setCurrentStreamer(?StationStreamer $current_streamer): void
|
||||
public function setCurrentStreamer(?StationStreamer $currentStreamer): void
|
||||
{
|
||||
if (null !== $this->current_streamer || null !== $current_streamer) {
|
||||
$this->current_streamer = $current_streamer;
|
||||
if (null !== $this->current_streamer || null !== $currentStreamer) {
|
||||
$this->current_streamer = $currentStreamer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -994,12 +994,12 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->fallback_path;
|
||||
}
|
||||
|
||||
public function setFallbackPath(?string $fallback_path): void
|
||||
public function setFallbackPath(?string $fallbackPath): void
|
||||
{
|
||||
if ($this->fallback_path !== $fallback_path) {
|
||||
if ($this->fallback_path !== $fallbackPath) {
|
||||
$this->setNeedsRestart(true);
|
||||
}
|
||||
$this->fallback_path = $fallback_path;
|
||||
$this->fallback_path = $fallbackPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1071,9 +1071,9 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
return $this->current_song;
|
||||
}
|
||||
|
||||
public function setCurrentSong(?SongHistory $current_song): void
|
||||
public function setCurrentSong(?SongHistory $currentSong): void
|
||||
{
|
||||
$this->current_song = $current_song;
|
||||
$this->current_song = $currentSong;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
@ -1105,14 +1105,14 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
$this->podcasts_storage_location = null;
|
||||
|
||||
// Clear ports
|
||||
$fe_config = $this->getFrontendConfig();
|
||||
$fe_config->setPort(null);
|
||||
$this->setFrontendConfig($fe_config);
|
||||
$feConfig = $this->getFrontendConfig();
|
||||
$feConfig->setPort(null);
|
||||
$this->setFrontendConfig($feConfig);
|
||||
|
||||
$be_config = $this->getBackendConfig();
|
||||
$be_config->setDjPort(null);
|
||||
$be_config->setTelnetPort(null);
|
||||
$this->setBackendConfig($be_config);
|
||||
$beConfig = $this->getBackendConfig();
|
||||
$beConfig->setDjPort(null);
|
||||
$beConfig->setTelnetPort(null);
|
||||
$this->setBackendConfig($beConfig);
|
||||
}
|
||||
|
||||
public static function generateShortName(string $str): string
|
||||
|
|
|
@ -25,9 +25,9 @@ class StationBrandingConfiguration extends AbstractStationConfiguration
|
|||
);
|
||||
}
|
||||
|
||||
public function setDefaultAlbumArtUrl(?string $default_album_art_url): void
|
||||
public function setDefaultAlbumArtUrl(?string $defaultAlbumArtUrl): void
|
||||
{
|
||||
$this->set(self::DEFAULT_ALBUM_ART_URL, $default_album_art_url);
|
||||
$this->set(self::DEFAULT_ALBUM_ART_URL, $defaultAlbumArtUrl);
|
||||
}
|
||||
|
||||
public const PUBLIC_CUSTOM_CSS = 'public_custom_css';
|
||||
|
|
|
@ -80,10 +80,10 @@ class StationHlsStream implements
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $new_name): void
|
||||
public function setName(string $newName): void
|
||||
{
|
||||
// Ensure all mount point names start with a leading slash.
|
||||
$this->name = $this->truncateString(Strings::getProgrammaticString($new_name), 100);
|
||||
$this->name = $this->truncateString(Strings::getProgrammaticString($newName), 100);
|
||||
}
|
||||
|
||||
public function getFormat(): ?StreamFormats
|
||||
|
|
|
@ -228,13 +228,13 @@ class StationMedia implements
|
|||
/**
|
||||
* Generate a new unique ID for this item.
|
||||
*
|
||||
* @param bool $force_new
|
||||
* @param bool $forceNew
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function generateUniqueId(bool $force_new = false): void
|
||||
public function generateUniqueId(bool $forceNew = false): void
|
||||
{
|
||||
if (!isset($this->unique_id) || $force_new) {
|
||||
if (!isset($this->unique_id) || $forceNew) {
|
||||
$this->unique_id = bin2hex(random_bytes(12));
|
||||
}
|
||||
}
|
||||
|
@ -305,11 +305,11 @@ class StationMedia implements
|
|||
*/
|
||||
public function setLength(int $length): void
|
||||
{
|
||||
$length_min = floor($length / 60);
|
||||
$length_sec = $length % 60;
|
||||
$lengthMin = floor($length / 60);
|
||||
$lengthSec = $length % 60;
|
||||
|
||||
$this->length = (float)$length;
|
||||
$this->length_text = $length_min . ':' . str_pad((string)$length_sec, 2, '0', STR_PAD_LEFT);
|
||||
$this->length_text = $lengthMin . ':' . str_pad((string)$lengthSec, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function getLengthText(): ?string
|
||||
|
@ -317,9 +317,9 @@ class StationMedia implements
|
|||
return $this->length_text;
|
||||
}
|
||||
|
||||
public function setLengthText(?string $length_text = null): void
|
||||
public function setLengthText(?string $lengthText = null): void
|
||||
{
|
||||
$this->length_text = $length_text;
|
||||
$this->length_text = $lengthText;
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
|
@ -357,9 +357,9 @@ class StationMedia implements
|
|||
return $this->fade_overlap;
|
||||
}
|
||||
|
||||
public function setFadeOverlap(?float $fade_overlap = null): void
|
||||
public function setFadeOverlap(?float $fadeOverlap = null): void
|
||||
{
|
||||
$this->fade_overlap = $fade_overlap;
|
||||
$this->fade_overlap = $fadeOverlap;
|
||||
}
|
||||
|
||||
public function getFadeIn(): ?float
|
||||
|
@ -367,9 +367,9 @@ class StationMedia implements
|
|||
return $this->fade_in;
|
||||
}
|
||||
|
||||
public function setFadeIn(string|int|float $fade_in = null): void
|
||||
public function setFadeIn(string|int|float $fadeIn = null): void
|
||||
{
|
||||
$this->fade_in = Time::displayTimeToSeconds($fade_in);
|
||||
$this->fade_in = Time::displayTimeToSeconds($fadeIn);
|
||||
}
|
||||
|
||||
public function getFadeOut(): ?float
|
||||
|
@ -377,9 +377,9 @@ class StationMedia implements
|
|||
return $this->fade_out;
|
||||
}
|
||||
|
||||
public function setFadeOut(string|int|float $fade_out = null): void
|
||||
public function setFadeOut(string|int|float $fadeOut = null): void
|
||||
{
|
||||
$this->fade_out = Time::displayTimeToSeconds($fade_out);
|
||||
$this->fade_out = Time::displayTimeToSeconds($fadeOut);
|
||||
}
|
||||
|
||||
public function getCueIn(): ?float
|
||||
|
@ -387,9 +387,9 @@ class StationMedia implements
|
|||
return $this->cue_in;
|
||||
}
|
||||
|
||||
public function setCueIn(string|int|float $cue_in = null): void
|
||||
public function setCueIn(string|int|float $cueIn = null): void
|
||||
{
|
||||
$this->cue_in = Time::displayTimeToSeconds($cue_in);
|
||||
$this->cue_in = Time::displayTimeToSeconds($cueIn);
|
||||
}
|
||||
|
||||
public function getCueOut(): ?float
|
||||
|
@ -397,9 +397,9 @@ class StationMedia implements
|
|||
return $this->cue_out;
|
||||
}
|
||||
|
||||
public function setCueOut(string|int|float $cue_out = null): void
|
||||
public function setCueOut(string|int|float $cueOut = null): void
|
||||
{
|
||||
$this->cue_out = Time::displayTimeToSeconds($cue_out);
|
||||
$this->cue_out = Time::displayTimeToSeconds($cueOut);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,8 +410,8 @@ class StationMedia implements
|
|||
$length = (int)$this->length;
|
||||
|
||||
if ((int)$this->cue_out > 0) {
|
||||
$length_removed = $length - (int)$this->cue_out;
|
||||
$length -= $length_removed;
|
||||
$lengthRemoved = $length - (int)$this->cue_out;
|
||||
$length -= $lengthRemoved;
|
||||
}
|
||||
if ((int)$this->cue_in > 0) {
|
||||
$length -= $this->cue_in;
|
||||
|
@ -425,9 +425,9 @@ class StationMedia implements
|
|||
return $this->art_updated_at;
|
||||
}
|
||||
|
||||
public function setArtUpdatedAt(int $art_updated_at): void
|
||||
public function setArtUpdatedAt(int $artUpdatedAt): void
|
||||
{
|
||||
$this->art_updated_at = $art_updated_at;
|
||||
$this->art_updated_at = $artUpdatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -439,11 +439,11 @@ class StationMedia implements
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, StationMediaCustomField> $custom_fields
|
||||
* @param Collection<int, StationMediaCustomField> $customFields
|
||||
*/
|
||||
public function setCustomFields(Collection $custom_fields): void
|
||||
public function setCustomFields(Collection $customFields): void
|
||||
{
|
||||
$this->custom_fields = $custom_fields;
|
||||
$this->custom_fields = $customFields;
|
||||
}
|
||||
|
||||
public static function needsReprocessing(int $fileModifiedTime = 0, int $dbModifiedTime = 0): bool
|
||||
|
@ -456,8 +456,8 @@ class StationMedia implements
|
|||
*/
|
||||
public function isRequestable(): bool
|
||||
{
|
||||
foreach ($this->getPlaylists() as $playlist_item) {
|
||||
$playlist = $playlist_item->getPlaylist();
|
||||
foreach ($this->getPlaylists() as $playlistItem) {
|
||||
$playlist = $playlistItem->getPlaylist();
|
||||
/** @var StationPlaylist $playlist */
|
||||
if ($playlist->isRequestable()) {
|
||||
return true;
|
||||
|
|
|
@ -169,10 +169,10 @@ class StationMount implements
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $new_name): void
|
||||
public function setName(string $newName): void
|
||||
{
|
||||
// Ensure all mount point names start with a leading slash.
|
||||
$this->name = $this->truncateString('/' . ltrim($new_name, '/'), 100);
|
||||
$this->name = $this->truncateString('/' . ltrim($newName, '/'), 100);
|
||||
}
|
||||
|
||||
public function getDisplayName(): string
|
||||
|
@ -192,9 +192,9 @@ class StationMount implements
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public function setDisplayName(?string $display_name): void
|
||||
public function setDisplayName(?string $displayName): void
|
||||
{
|
||||
$this->display_name = $this->truncateNullableString($display_name);
|
||||
$this->display_name = $this->truncateNullableString($displayName);
|
||||
}
|
||||
|
||||
public function getIsVisibleOnPublicPages(): bool
|
||||
|
@ -202,9 +202,9 @@ class StationMount implements
|
|||
return $this->is_visible_on_public_pages;
|
||||
}
|
||||
|
||||
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
|
||||
public function setIsVisibleOnPublicPages(bool $isVisibleOnPublicPages): void
|
||||
{
|
||||
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
|
||||
$this->is_visible_on_public_pages = $isVisibleOnPublicPages;
|
||||
}
|
||||
|
||||
public function getIsDefault(): bool
|
||||
|
@ -212,9 +212,9 @@ class StationMount implements
|
|||
return $this->is_default;
|
||||
}
|
||||
|
||||
public function setIsDefault(bool $is_default): void
|
||||
public function setIsDefault(bool $isDefault): void
|
||||
{
|
||||
$this->is_default = $is_default;
|
||||
$this->is_default = $isDefault;
|
||||
}
|
||||
|
||||
public function getIsPublic(): bool
|
||||
|
@ -222,9 +222,9 @@ class StationMount implements
|
|||
return $this->is_public;
|
||||
}
|
||||
|
||||
public function setIsPublic(bool $is_public): void
|
||||
public function setIsPublic(bool $isPublic): void
|
||||
{
|
||||
$this->is_public = $is_public;
|
||||
$this->is_public = $isPublic;
|
||||
}
|
||||
|
||||
public function getFallbackMount(): ?string
|
||||
|
@ -232,9 +232,9 @@ class StationMount implements
|
|||
return $this->fallback_mount;
|
||||
}
|
||||
|
||||
public function setFallbackMount(?string $fallback_mount = null): void
|
||||
public function setFallbackMount(?string $fallbackMount = null): void
|
||||
{
|
||||
$this->fallback_mount = $fallback_mount;
|
||||
$this->fallback_mount = $fallbackMount;
|
||||
}
|
||||
|
||||
public function getRelayUrl(): ?string
|
||||
|
@ -262,9 +262,9 @@ class StationMount implements
|
|||
return $relayUri;
|
||||
}
|
||||
|
||||
public function setRelayUrl(?string $relay_url = null): void
|
||||
public function setRelayUrl(?string $relayUrl = null): void
|
||||
{
|
||||
$this->relay_url = $this->truncateNullableString($relay_url);
|
||||
$this->relay_url = $this->truncateNullableString($relayUrl);
|
||||
}
|
||||
|
||||
public function getAuthhash(): ?string
|
||||
|
@ -282,9 +282,9 @@ class StationMount implements
|
|||
return $this->max_listener_duration;
|
||||
}
|
||||
|
||||
public function setMaxListenerDuration(int $max_listener_duration): void
|
||||
public function setMaxListenerDuration(int $maxListenerDuration): void
|
||||
{
|
||||
$this->max_listener_duration = $this->truncateInt($max_listener_duration);
|
||||
$this->max_listener_duration = $this->truncateInt($maxListenerDuration);
|
||||
}
|
||||
|
||||
public function getEnableAutodj(): bool
|
||||
|
@ -292,9 +292,9 @@ class StationMount implements
|
|||
return $this->enable_autodj;
|
||||
}
|
||||
|
||||
public function setEnableAutodj(bool $enable_autodj): void
|
||||
public function setEnableAutodj(bool $enableAutodj): void
|
||||
{
|
||||
$this->enable_autodj = $enable_autodj;
|
||||
$this->enable_autodj = $enableAutodj;
|
||||
}
|
||||
|
||||
public function getAutodjFormat(): ?StreamFormats
|
||||
|
@ -302,9 +302,9 @@ class StationMount implements
|
|||
return $this->autodj_format;
|
||||
}
|
||||
|
||||
public function setAutodjFormat(?StreamFormats $autodj_format = null): void
|
||||
public function setAutodjFormat(?StreamFormats $autodjFormat = null): void
|
||||
{
|
||||
$this->autodj_format = $autodj_format;
|
||||
$this->autodj_format = $autodjFormat;
|
||||
}
|
||||
|
||||
public function getAutodjBitrate(): ?int
|
||||
|
@ -312,9 +312,9 @@ class StationMount implements
|
|||
return $this->autodj_bitrate;
|
||||
}
|
||||
|
||||
public function setAutodjBitrate(?int $autodj_bitrate = null): void
|
||||
public function setAutodjBitrate(?int $autodjBitrate = null): void
|
||||
{
|
||||
$this->autodj_bitrate = $autodj_bitrate;
|
||||
$this->autodj_bitrate = $autodjBitrate;
|
||||
}
|
||||
|
||||
public function getCustomListenUrl(): ?string
|
||||
|
@ -330,9 +330,9 @@ class StationMount implements
|
|||
);
|
||||
}
|
||||
|
||||
public function setCustomListenUrl(?string $custom_listen_url = null): void
|
||||
public function setCustomListenUrl(?string $customListenUrl = null): void
|
||||
{
|
||||
$this->custom_listen_url = $this->truncateNullableString($custom_listen_url);
|
||||
$this->custom_listen_url = $this->truncateNullableString($customListenUrl);
|
||||
}
|
||||
|
||||
public function getFrontendConfig(): ?string
|
||||
|
@ -340,9 +340,9 @@ class StationMount implements
|
|||
return $this->frontend_config;
|
||||
}
|
||||
|
||||
public function setFrontendConfig(?string $frontend_config = null): void
|
||||
public function setFrontendConfig(?string $frontendConfig = null): void
|
||||
{
|
||||
$this->frontend_config = $frontend_config;
|
||||
$this->frontend_config = $frontendConfig;
|
||||
}
|
||||
|
||||
public function getListenersUnique(): int
|
||||
|
@ -350,9 +350,9 @@ class StationMount implements
|
|||
return $this->listeners_unique;
|
||||
}
|
||||
|
||||
public function setListenersUnique(int $listeners_unique): void
|
||||
public function setListenersUnique(int $listenersUnique): void
|
||||
{
|
||||
$this->listeners_unique = $listeners_unique;
|
||||
$this->listeners_unique = $listenersUnique;
|
||||
}
|
||||
|
||||
public function getListenersTotal(): int
|
||||
|
@ -360,9 +360,9 @@ class StationMount implements
|
|||
return $this->listeners_total;
|
||||
}
|
||||
|
||||
public function setListenersTotal(int $listeners_total): void
|
||||
public function setListenersTotal(int $listenersTotal): void
|
||||
{
|
||||
$this->listeners_total = $listeners_total;
|
||||
$this->listeners_total = $listenersTotal;
|
||||
}
|
||||
|
||||
public function getIntroPath(): ?string
|
||||
|
@ -370,9 +370,9 @@ class StationMount implements
|
|||
return $this->intro_path;
|
||||
}
|
||||
|
||||
public function setIntroPath(?string $intro_path): void
|
||||
public function setIntroPath(?string $introPath): void
|
||||
{
|
||||
$this->intro_path = $intro_path;
|
||||
$this->intro_path = $introPath;
|
||||
}
|
||||
|
||||
public function getAutodjHost(): ?string
|
||||
|
@ -425,11 +425,11 @@ class StationMount implements
|
|||
* Retrieve the API version of the object/array.
|
||||
*
|
||||
* @param AbstractFrontend $fa
|
||||
* @param UriInterface|null $base_url
|
||||
* @param UriInterface|null $baseUrl
|
||||
*/
|
||||
public function api(
|
||||
AbstractFrontend $fa,
|
||||
UriInterface $base_url = null
|
||||
UriInterface $baseUrl = null
|
||||
): Api\NowPlaying\StationMount {
|
||||
$response = new Api\NowPlaying\StationMount();
|
||||
|
||||
|
@ -437,7 +437,7 @@ class StationMount implements
|
|||
$response->name = $this->getDisplayName();
|
||||
$response->path = $this->getName();
|
||||
$response->is_default = $this->is_default;
|
||||
$response->url = $fa->getUrlForMount($this->station, $this, $base_url);
|
||||
$response->url = $fa->getUrlForMount($this->station, $this, $baseUrl);
|
||||
|
||||
$response->listeners = new Api\NowPlaying\Listeners(
|
||||
total: $this->listeners_total,
|
||||
|
|
|
@ -273,9 +273,9 @@ class StationPlaylist implements
|
|||
return $this->remote_url;
|
||||
}
|
||||
|
||||
public function setRemoteUrl(?string $remote_url): void
|
||||
public function setRemoteUrl(?string $remoteUrl): void
|
||||
{
|
||||
$this->remote_url = $remote_url;
|
||||
$this->remote_url = $remoteUrl;
|
||||
}
|
||||
|
||||
public function getRemoteType(): ?PlaylistRemoteTypes
|
||||
|
@ -283,9 +283,9 @@ class StationPlaylist implements
|
|||
return $this->remote_type;
|
||||
}
|
||||
|
||||
public function setRemoteType(?PlaylistRemoteTypes $remote_type): void
|
||||
public function setRemoteType(?PlaylistRemoteTypes $remoteType): void
|
||||
{
|
||||
$this->remote_type = $remote_type;
|
||||
$this->remote_type = $remoteType;
|
||||
}
|
||||
|
||||
public function getRemoteBuffer(): int
|
||||
|
@ -293,9 +293,9 @@ class StationPlaylist implements
|
|||
return $this->remote_buffer;
|
||||
}
|
||||
|
||||
public function setRemoteBuffer(int $remote_buffer): void
|
||||
public function setRemoteBuffer(int $remoteBuffer): void
|
||||
{
|
||||
$this->remote_buffer = $remote_buffer;
|
||||
$this->remote_buffer = $remoteBuffer;
|
||||
}
|
||||
|
||||
public function getIsEnabled(): bool
|
||||
|
@ -303,9 +303,9 @@ class StationPlaylist implements
|
|||
return $this->is_enabled;
|
||||
}
|
||||
|
||||
public function setIsEnabled(bool $is_enabled): void
|
||||
public function setIsEnabled(bool $isEnabled): void
|
||||
{
|
||||
$this->is_enabled = $is_enabled;
|
||||
$this->is_enabled = $isEnabled;
|
||||
}
|
||||
|
||||
public function getIsJingle(): bool
|
||||
|
@ -313,9 +313,9 @@ class StationPlaylist implements
|
|||
return $this->is_jingle;
|
||||
}
|
||||
|
||||
public function setIsJingle(bool $is_jingle): void
|
||||
public function setIsJingle(bool $isJingle): void
|
||||
{
|
||||
$this->is_jingle = $is_jingle;
|
||||
$this->is_jingle = $isJingle;
|
||||
}
|
||||
|
||||
public function getWeight(): int
|
||||
|
@ -337,9 +337,9 @@ class StationPlaylist implements
|
|||
return $this->include_in_requests;
|
||||
}
|
||||
|
||||
public function setIncludeInRequests(bool $include_in_requests): void
|
||||
public function setIncludeInRequests(bool $includeInRequests): void
|
||||
{
|
||||
$this->include_in_requests = $include_in_requests;
|
||||
$this->include_in_requests = $includeInRequests;
|
||||
}
|
||||
|
||||
public function getIncludeInOnDemand(): bool
|
||||
|
@ -347,9 +347,9 @@ class StationPlaylist implements
|
|||
return $this->include_in_on_demand;
|
||||
}
|
||||
|
||||
public function setIncludeInOnDemand(bool $include_in_on_demand): void
|
||||
public function setIncludeInOnDemand(bool $includeInOnDemand): void
|
||||
{
|
||||
$this->include_in_on_demand = $include_in_on_demand;
|
||||
$this->include_in_on_demand = $includeInOnDemand;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -365,9 +365,9 @@ class StationPlaylist implements
|
|||
return $this->avoid_duplicates;
|
||||
}
|
||||
|
||||
public function setAvoidDuplicates(bool $avoid_duplicates): void
|
||||
public function setAvoidDuplicates(bool $avoidDuplicates): void
|
||||
{
|
||||
$this->avoid_duplicates = $avoid_duplicates;
|
||||
$this->avoid_duplicates = $avoidDuplicates;
|
||||
}
|
||||
|
||||
public function getPlayedAt(): int
|
||||
|
@ -375,9 +375,9 @@ class StationPlaylist implements
|
|||
return $this->played_at;
|
||||
}
|
||||
|
||||
public function setPlayedAt(int $played_at): void
|
||||
public function setPlayedAt(int $playedAt): void
|
||||
{
|
||||
$this->played_at = $played_at;
|
||||
$this->played_at = $playedAt;
|
||||
}
|
||||
|
||||
public function getQueueResetAt(): int
|
||||
|
@ -385,9 +385,9 @@ class StationPlaylist implements
|
|||
return $this->queue_reset_at;
|
||||
}
|
||||
|
||||
public function setQueueResetAt(int $queue_reset_at): void
|
||||
public function setQueueResetAt(int $queueResetAt): void
|
||||
{
|
||||
$this->queue_reset_at = $queue_reset_at;
|
||||
$this->queue_reset_at = $queueResetAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -446,29 +446,29 @@ class StationPlaylist implements
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $backend_options
|
||||
* @param array $backendOptions
|
||||
*/
|
||||
public function setBackendOptions(array $backend_options): void
|
||||
public function setBackendOptions(array $backendOptions): void
|
||||
{
|
||||
$this->backend_options = implode(',', $backend_options);
|
||||
$this->backend_options = implode(',', $backendOptions);
|
||||
}
|
||||
|
||||
public function backendInterruptOtherSongs(): bool
|
||||
{
|
||||
$backend_options = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_INTERRUPT_OTHER_SONGS, $backend_options, true);
|
||||
$backendOptions = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_INTERRUPT_OTHER_SONGS, $backendOptions, true);
|
||||
}
|
||||
|
||||
public function backendMerge(): bool
|
||||
{
|
||||
$backend_options = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_MERGE, $backend_options, true);
|
||||
$backendOptions = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_MERGE, $backendOptions, true);
|
||||
}
|
||||
|
||||
public function backendPlaySingleTrack(): bool
|
||||
{
|
||||
$backend_options = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_PLAY_SINGLE_TRACK, $backend_options, true);
|
||||
$backendOptions = $this->getBackendOptions();
|
||||
return in_array(self::OPTION_PLAY_SINGLE_TRACK, $backendOptions, true);
|
||||
}
|
||||
|
||||
public function getPlayPerHourMinute(): int
|
||||
|
@ -476,13 +476,13 @@ class StationPlaylist implements
|
|||
return $this->play_per_hour_minute;
|
||||
}
|
||||
|
||||
public function setPlayPerHourMinute(int $play_per_hour_minute): void
|
||||
public function setPlayPerHourMinute(int $playPerHourMinute): void
|
||||
{
|
||||
if ($play_per_hour_minute > 59 || $play_per_hour_minute < 0) {
|
||||
$play_per_hour_minute = 0;
|
||||
if ($playPerHourMinute > 59 || $playPerHourMinute < 0) {
|
||||
$playPerHourMinute = 0;
|
||||
}
|
||||
|
||||
$this->play_per_hour_minute = $play_per_hour_minute;
|
||||
$this->play_per_hour_minute = $playPerHourMinute;
|
||||
}
|
||||
|
||||
public function getPlayPerSongs(): int
|
||||
|
@ -490,9 +490,9 @@ class StationPlaylist implements
|
|||
return $this->play_per_songs;
|
||||
}
|
||||
|
||||
public function setPlayPerSongs(int $play_per_songs): void
|
||||
public function setPlayPerSongs(int $playPerSongs): void
|
||||
{
|
||||
$this->play_per_songs = $play_per_songs;
|
||||
$this->play_per_songs = $playPerSongs;
|
||||
}
|
||||
|
||||
public function getPlayPerMinutes(): int
|
||||
|
@ -501,9 +501,9 @@ class StationPlaylist implements
|
|||
}
|
||||
|
||||
public function setPlayPerMinutes(
|
||||
int $play_per_minutes
|
||||
int $playPerMinutes
|
||||
): void {
|
||||
$this->play_per_minutes = $play_per_minutes;
|
||||
$this->play_per_minutes = $playPerMinutes;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
|
|
|
@ -128,9 +128,9 @@ class StationQueue implements
|
|||
return $this->autodj_custom_uri;
|
||||
}
|
||||
|
||||
public function setAutodjCustomUri(?string $autodj_custom_uri): void
|
||||
public function setAutodjCustomUri(?string $autodjCustomUri): void
|
||||
{
|
||||
$this->autodj_custom_uri = $autodj_custom_uri;
|
||||
$this->autodj_custom_uri = $autodjCustomUri;
|
||||
}
|
||||
|
||||
public function getTimestampCued(): int
|
||||
|
@ -138,9 +138,9 @@ class StationQueue implements
|
|||
return $this->timestamp_cued;
|
||||
}
|
||||
|
||||
public function setTimestampCued(int $timestamp_cued): void
|
||||
public function setTimestampCued(int $timestampCued): void
|
||||
{
|
||||
$this->timestamp_cued = $timestamp_cued;
|
||||
$this->timestamp_cued = $timestampCued;
|
||||
}
|
||||
|
||||
public function getDuration(): ?int
|
||||
|
@ -182,9 +182,9 @@ class StationQueue implements
|
|||
return $this->is_visible;
|
||||
}
|
||||
|
||||
public function setIsVisible(bool $is_visible): void
|
||||
public function setIsVisible(bool $isVisible): void
|
||||
{
|
||||
$this->is_visible = $is_visible;
|
||||
$this->is_visible = $isVisible;
|
||||
}
|
||||
|
||||
public function updateVisibility(): void
|
||||
|
@ -197,9 +197,9 @@ class StationQueue implements
|
|||
return $this->timestamp_played;
|
||||
}
|
||||
|
||||
public function setTimestampPlayed(int $timestamp_played): void
|
||||
public function setTimestampPlayed(int $timestampPlayed): void
|
||||
{
|
||||
$this->timestamp_played = $timestamp_played;
|
||||
$this->timestamp_played = $timestampPlayed;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
|
|
@ -125,9 +125,9 @@ class StationRemote implements
|
|||
return $this->is_visible_on_public_pages;
|
||||
}
|
||||
|
||||
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
|
||||
public function setIsVisibleOnPublicPages(bool $isVisibleOnPublicPages): void
|
||||
{
|
||||
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
|
||||
$this->is_visible_on_public_pages = $isVisibleOnPublicPages;
|
||||
}
|
||||
|
||||
public function getEnableAutodj(): bool
|
||||
|
@ -135,9 +135,9 @@ class StationRemote implements
|
|||
return $this->enable_autodj;
|
||||
}
|
||||
|
||||
public function setEnableAutodj(bool $enable_autodj): void
|
||||
public function setEnableAutodj(bool $enableAutodj): void
|
||||
{
|
||||
$this->enable_autodj = $enable_autodj;
|
||||
$this->enable_autodj = $enableAutodj;
|
||||
}
|
||||
|
||||
public function getAutodjFormat(): ?StreamFormats
|
||||
|
@ -145,9 +145,9 @@ class StationRemote implements
|
|||
return $this->autodj_format;
|
||||
}
|
||||
|
||||
public function setAutodjFormat(?StreamFormats $autodj_format = null): void
|
||||
public function setAutodjFormat(?StreamFormats $autodjFormat = null): void
|
||||
{
|
||||
$this->autodj_format = $autodj_format;
|
||||
$this->autodj_format = $autodjFormat;
|
||||
}
|
||||
|
||||
public function getAutodjBitrate(): ?int
|
||||
|
@ -155,9 +155,9 @@ class StationRemote implements
|
|||
return $this->autodj_bitrate;
|
||||
}
|
||||
|
||||
public function setAutodjBitrate(int $autodj_bitrate = null): void
|
||||
public function setAutodjBitrate(int $autodjBitrate = null): void
|
||||
{
|
||||
$this->autodj_bitrate = $autodj_bitrate;
|
||||
$this->autodj_bitrate = $autodjBitrate;
|
||||
}
|
||||
|
||||
public function getCustomListenUrl(): ?string
|
||||
|
@ -165,9 +165,9 @@ class StationRemote implements
|
|||
return $this->custom_listen_url;
|
||||
}
|
||||
|
||||
public function setCustomListenUrl(?string $custom_listen_url = null): void
|
||||
public function setCustomListenUrl(?string $customListenUrl = null): void
|
||||
{
|
||||
$this->custom_listen_url = $this->truncateNullableString($custom_listen_url);
|
||||
$this->custom_listen_url = $this->truncateNullableString($customListenUrl);
|
||||
}
|
||||
|
||||
public function getAutodjUsername(): ?string
|
||||
|
@ -180,9 +180,9 @@ class StationRemote implements
|
|||
return $this->source_username;
|
||||
}
|
||||
|
||||
public function setSourceUsername(?string $source_username): void
|
||||
public function setSourceUsername(?string $sourceUsername): void
|
||||
{
|
||||
$this->source_username = $this->truncateNullableString($source_username, 100);
|
||||
$this->source_username = $this->truncateNullableString($sourceUsername, 100);
|
||||
}
|
||||
|
||||
public function getAutodjPassword(): ?string
|
||||
|
@ -208,9 +208,9 @@ class StationRemote implements
|
|||
return $this->source_password;
|
||||
}
|
||||
|
||||
public function setSourcePassword(?string $source_password): void
|
||||
public function setSourcePassword(?string $sourcePassword): void
|
||||
{
|
||||
$this->source_password = $this->truncateNullableString($source_password, 100);
|
||||
$this->source_password = $this->truncateNullableString($sourcePassword, 100);
|
||||
}
|
||||
|
||||
public function getType(): RemoteAdapters
|
||||
|
@ -228,9 +228,9 @@ class StationRemote implements
|
|||
return $this->source_mount;
|
||||
}
|
||||
|
||||
public function setSourceMount(?string $source_mount): void
|
||||
public function setSourceMount(?string $sourceMount): void
|
||||
{
|
||||
$this->source_mount = $this->truncateNullableString($source_mount, 150);
|
||||
$this->source_mount = $this->truncateNullableString($sourceMount, 150);
|
||||
}
|
||||
|
||||
public function getMount(): ?string
|
||||
|
@ -248,9 +248,9 @@ class StationRemote implements
|
|||
return $this->admin_password;
|
||||
}
|
||||
|
||||
public function setAdminPassword(?string $admin_password): void
|
||||
public function setAdminPassword(?string $adminPassword): void
|
||||
{
|
||||
$this->admin_password = $admin_password;
|
||||
$this->admin_password = $adminPassword;
|
||||
}
|
||||
|
||||
public function getAutodjMount(): ?string
|
||||
|
@ -313,13 +313,13 @@ class StationRemote implements
|
|||
return $this->source_port;
|
||||
}
|
||||
|
||||
public function setSourcePort(?int $source_port): void
|
||||
public function setSourcePort(?int $sourcePort): void
|
||||
{
|
||||
if ((int)$source_port === 0) {
|
||||
$source_port = null;
|
||||
if ((int)$sourcePort === 0) {
|
||||
$sourcePort = null;
|
||||
}
|
||||
|
||||
$this->source_port = $source_port;
|
||||
$this->source_port = $sourcePort;
|
||||
}
|
||||
|
||||
public function getAutodjProtocol(): ?StreamProtocols
|
||||
|
@ -342,9 +342,9 @@ class StationRemote implements
|
|||
return $this->is_public;
|
||||
}
|
||||
|
||||
public function setIsPublic(bool $is_public): void
|
||||
public function setIsPublic(bool $isPublic): void
|
||||
{
|
||||
$this->is_public = $is_public;
|
||||
$this->is_public = $isPublic;
|
||||
}
|
||||
|
||||
public function getListenersUnique(): int
|
||||
|
@ -352,9 +352,9 @@ class StationRemote implements
|
|||
return $this->listeners_unique;
|
||||
}
|
||||
|
||||
public function setListenersUnique(int $listeners_unique): void
|
||||
public function setListenersUnique(int $listenersUnique): void
|
||||
{
|
||||
$this->listeners_unique = $listeners_unique;
|
||||
$this->listeners_unique = $listenersUnique;
|
||||
}
|
||||
|
||||
public function getListenersTotal(): int
|
||||
|
@ -362,9 +362,9 @@ class StationRemote implements
|
|||
return $this->listeners_total;
|
||||
}
|
||||
|
||||
public function setListenersTotal(int $listeners_total): void
|
||||
public function setListenersTotal(int $listenersTotal): void
|
||||
{
|
||||
$this->listeners_total = $listeners_total;
|
||||
$this->listeners_total = $listenersTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,11 +427,11 @@ class StationRemote implements
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string|null $display_name
|
||||
* @param string|null $displayName
|
||||
*/
|
||||
public function setDisplayName(?string $display_name): void
|
||||
public function setDisplayName(?string $displayName): void
|
||||
{
|
||||
$this->display_name = $this->truncateNullableString($display_name);
|
||||
$this->display_name = $this->truncateNullableString($displayName);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
|
|
@ -84,9 +84,9 @@ class StationRequest implements
|
|||
return $this->played_at;
|
||||
}
|
||||
|
||||
public function setPlayedAt(int $played_at): void
|
||||
public function setPlayedAt(int $playedAt): void
|
||||
{
|
||||
$this->played_at = $played_at;
|
||||
$this->played_at = $playedAt;
|
||||
}
|
||||
|
||||
public function getIp(): string
|
||||
|
|
|
@ -102,9 +102,9 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
return $this->start_time;
|
||||
}
|
||||
|
||||
public function setStartTime(int $start_time): void
|
||||
public function setStartTime(int $startTime): void
|
||||
{
|
||||
$this->start_time = $start_time;
|
||||
$this->start_time = $startTime;
|
||||
}
|
||||
|
||||
public function getEndTime(): int
|
||||
|
@ -112,9 +112,9 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
return $this->end_time;
|
||||
}
|
||||
|
||||
public function setEndTime(int $end_time): void
|
||||
public function setEndTime(int $endTime): void
|
||||
{
|
||||
$this->end_time = $end_time;
|
||||
$this->end_time = $endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,18 +124,18 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
{
|
||||
$now = CarbonImmutable::now(new DateTimeZone('UTC'));
|
||||
|
||||
$start_time = self::getDateTime($this->start_time, $now)
|
||||
$startTime = self::getDateTime($this->start_time, $now)
|
||||
->getTimestamp();
|
||||
|
||||
$end_time = self::getDateTime($this->end_time, $now)
|
||||
$endTime = self::getDateTime($this->end_time, $now)
|
||||
->getTimestamp();
|
||||
|
||||
if ($start_time > $end_time) {
|
||||
if ($startTime > $endTime) {
|
||||
/** @noinspection SummerTimeUnsafeTimeManipulationInspection */
|
||||
return 86400 - ($start_time - $end_time);
|
||||
return 86400 - ($startTime - $endTime);
|
||||
}
|
||||
|
||||
return $end_time - $start_time;
|
||||
return $endTime - $startTime;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?string
|
||||
|
@ -143,9 +143,9 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
return $this->start_date;
|
||||
}
|
||||
|
||||
public function setStartDate(?string $start_date): void
|
||||
public function setStartDate(?string $startDate): void
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->start_date = $startDate;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?string
|
||||
|
@ -153,9 +153,9 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
return $this->end_date;
|
||||
}
|
||||
|
||||
public function setEndDate(?string $end_date): void
|
||||
public function setEndDate(?string $endDate): void
|
||||
{
|
||||
$this->end_date = $end_date;
|
||||
$this->end_date = $endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,9 +185,9 @@ class StationSchedule implements IdentifiableEntityInterface
|
|||
return $this->loop_once;
|
||||
}
|
||||
|
||||
public function setLoopOnce(bool $loop_once): void
|
||||
public function setLoopOnce(bool $loopOnce): void
|
||||
{
|
||||
$this->loop_once = $loop_once;
|
||||
$this->loop_once = $loopOnce;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
|
|
@ -128,9 +128,9 @@ class StationStreamer implements
|
|||
return $this->streamer_username;
|
||||
}
|
||||
|
||||
public function setStreamerUsername(string $streamer_username): void
|
||||
public function setStreamerUsername(string $streamerUsername): void
|
||||
{
|
||||
$this->streamer_username = $this->truncateString($streamer_username, 50);
|
||||
$this->streamer_username = $this->truncateString($streamerUsername, 50);
|
||||
}
|
||||
|
||||
public function getStreamerPassword(): string
|
||||
|
@ -138,12 +138,12 @@ class StationStreamer implements
|
|||
return '';
|
||||
}
|
||||
|
||||
public function setStreamerPassword(?string $streamer_password): void
|
||||
public function setStreamerPassword(?string $streamerPassword): void
|
||||
{
|
||||
$streamer_password = trim($streamer_password ?? '');
|
||||
$streamerPassword = trim($streamerPassword ?? '');
|
||||
|
||||
if (!empty($streamer_password)) {
|
||||
$this->streamer_password = password_hash($streamer_password, PASSWORD_ARGON2ID);
|
||||
if (!empty($streamerPassword)) {
|
||||
$this->streamer_password = password_hash($streamerPassword, PASSWORD_ARGON2ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,9 +159,9 @@ class StationStreamer implements
|
|||
: $this->streamer_username;
|
||||
}
|
||||
|
||||
public function setDisplayName(?string $display_name): void
|
||||
public function setDisplayName(?string $displayName): void
|
||||
{
|
||||
$this->display_name = $this->truncateNullableString($display_name);
|
||||
$this->display_name = $this->truncateNullableString($displayName);
|
||||
}
|
||||
|
||||
public function getComments(): ?string
|
||||
|
@ -179,12 +179,12 @@ class StationStreamer implements
|
|||
return $this->is_active;
|
||||
}
|
||||
|
||||
public function setIsActive(bool $is_active): void
|
||||
public function setIsActive(bool $isActive): void
|
||||
{
|
||||
$this->is_active = $is_active;
|
||||
$this->is_active = $isActive;
|
||||
|
||||
// Automatically set the "reactivate_at" flag to null if the DJ is for any reason reactivated.
|
||||
if (true === $is_active) {
|
||||
if (true === $isActive) {
|
||||
$this->reactivate_at = null;
|
||||
}
|
||||
}
|
||||
|
@ -194,9 +194,9 @@ class StationStreamer implements
|
|||
return $this->enforce_schedule;
|
||||
}
|
||||
|
||||
public function setEnforceSchedule(bool $enforce_schedule): void
|
||||
public function setEnforceSchedule(bool $enforceSchedule): void
|
||||
{
|
||||
$this->enforce_schedule = $enforce_schedule;
|
||||
$this->enforce_schedule = $enforceSchedule;
|
||||
}
|
||||
|
||||
public function getReactivateAt(): ?int
|
||||
|
@ -204,9 +204,9 @@ class StationStreamer implements
|
|||
return $this->reactivate_at;
|
||||
}
|
||||
|
||||
public function setReactivateAt(?int $reactivate_at): void
|
||||
public function setReactivateAt(?int $reactivateAt): void
|
||||
{
|
||||
$this->reactivate_at = $reactivate_at;
|
||||
$this->reactivate_at = $reactivateAt;
|
||||
}
|
||||
|
||||
public function deactivateFor(int $seconds): void
|
||||
|
@ -220,9 +220,9 @@ class StationStreamer implements
|
|||
return $this->art_updated_at;
|
||||
}
|
||||
|
||||
public function setArtUpdatedAt(int $art_updated_at): self
|
||||
public function setArtUpdatedAt(int $artUpdatedAt): self
|
||||
{
|
||||
$this->art_updated_at = $art_updated_at;
|
||||
$this->art_updated_at = $artUpdatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -245,8 +245,8 @@ class StationStreamer implements
|
|||
$this->reactivate_at = null;
|
||||
}
|
||||
|
||||
public static function getArtworkPath(int|string $streamer_id): string
|
||||
public static function getArtworkPath(int|string $streamerId): string
|
||||
{
|
||||
return 'streamer_' . $streamer_id . '.jpg';
|
||||
return 'streamer_' . $streamerId . '.jpg';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,9 +128,9 @@ class StationWebhook implements
|
|||
return $this->is_enabled;
|
||||
}
|
||||
|
||||
public function setIsEnabled(bool $is_enabled): void
|
||||
public function setIsEnabled(bool $isEnabled): void
|
||||
{
|
||||
$this->is_enabled = $is_enabled;
|
||||
$this->is_enabled = $isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -297,10 +297,10 @@ class StorageLocation implements Stringable, IdentifiableEntityInterface
|
|||
|
||||
public function getStorageQuota(): ?string
|
||||
{
|
||||
$raw_quota = $this->getStorageQuotaBytes();
|
||||
$rawQuota = $this->getStorageQuotaBytes();
|
||||
|
||||
return ($raw_quota instanceof BigInteger)
|
||||
? Quota::getReadableSize($raw_quota)
|
||||
return ($rawQuota instanceof BigInteger)
|
||||
? Quota::getReadableSize($rawQuota)
|
||||
: '';
|
||||
}
|
||||
|
||||
|
@ -324,8 +324,8 @@ class StorageLocation implements Stringable, IdentifiableEntityInterface
|
|||
|
||||
public function getStorageUsed(): ?string
|
||||
{
|
||||
$raw_size = $this->getStorageUsedBytes();
|
||||
return Quota::getReadableSize($raw_size);
|
||||
$rawSize = $this->getStorageUsedBytes();
|
||||
return Quota::getReadableSize($rawSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,10 +382,10 @@ class StorageLocation implements Stringable, IdentifiableEntityInterface
|
|||
|
||||
public function getStorageAvailable(): string
|
||||
{
|
||||
$raw_size = $this->getStorageAvailableBytes();
|
||||
$rawSize = $this->getStorageAvailableBytes();
|
||||
|
||||
return ($raw_size instanceof BigInteger)
|
||||
? Quota::getReadableSize($raw_size)
|
||||
return ($rawSize instanceof BigInteger)
|
||||
? Quota::getReadableSize($rawSize)
|
||||
: '';
|
||||
}
|
||||
|
||||
|
|
|
@ -49,19 +49,19 @@ trait TruncateInts
|
|||
}
|
||||
|
||||
protected function truncateIntToLimit(
|
||||
int $signed_limit,
|
||||
int $unsigned_limit,
|
||||
int $signedLimit,
|
||||
int $unsignedLimit,
|
||||
bool $unsigned,
|
||||
int $int
|
||||
): int {
|
||||
$lower_limit = $unsigned ? 0 : 0 - $signed_limit;
|
||||
$upper_limit = $unsigned ? $unsigned_limit : $signed_limit;
|
||||
$lowerLimit = $unsigned ? 0 : 0 - $signedLimit;
|
||||
$upperLimit = $unsigned ? $unsignedLimit : $signedLimit;
|
||||
|
||||
if ($int < $lower_limit) {
|
||||
return $lower_limit;
|
||||
if ($int < $lowerLimit) {
|
||||
return $lowerLimit;
|
||||
}
|
||||
if ($int > $upper_limit) {
|
||||
return $upper_limit;
|
||||
if ($int > $upperLimit) {
|
||||
return $upperLimit;
|
||||
}
|
||||
|
||||
return $int;
|
||||
|
|
|
@ -177,9 +177,9 @@ class User implements Stringable, IdentifiableEntityInterface
|
|||
public function verifyPassword(string $password): bool
|
||||
{
|
||||
if (password_verify($password, $this->auth_password)) {
|
||||
[$algo, $algo_opts] = $this->getPasswordAlgorithm();
|
||||
[$algo, $algoOpts] = $this->getPasswordAlgorithm();
|
||||
|
||||
if (password_needs_rehash($this->auth_password, $algo, $algo_opts)) {
|
||||
if (password_needs_rehash($this->auth_password, $algo, $algoOpts)) {
|
||||
$this->setNewPassword($password);
|
||||
}
|
||||
return true;
|
||||
|
@ -205,8 +205,8 @@ class User implements Stringable, IdentifiableEntityInterface
|
|||
public function setNewPassword(?string $password): void
|
||||
{
|
||||
if (null !== $password && trim($password)) {
|
||||
[$algo, $algo_opts] = $this->getPasswordAlgorithm();
|
||||
$this->auth_password = password_hash($password, $algo, $algo_opts);
|
||||
[$algo, $algoOpts] = $this->getPasswordAlgorithm();
|
||||
$this->auth_password = password_hash($password, $algo, $algoOpts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,9 +240,9 @@ class User implements Stringable, IdentifiableEntityInterface
|
|||
return $this->show_24_hour_time;
|
||||
}
|
||||
|
||||
public function setShow24HourTime(?bool $show_24_hour_time): void
|
||||
public function setShow24HourTime(?bool $show24HourTime): void
|
||||
{
|
||||
$this->show_24_hour_time = $show_24_hour_time;
|
||||
$this->show_24_hour_time = $show24HourTime;
|
||||
}
|
||||
|
||||
public function getTwoFactorSecret(): ?string
|
||||
|
@ -250,9 +250,9 @@ class User implements Stringable, IdentifiableEntityInterface
|
|||
return $this->two_factor_secret;
|
||||
}
|
||||
|
||||
public function setTwoFactorSecret(?string $two_factor_secret = null): void
|
||||
public function setTwoFactorSecret(?string $twoFactorSecret = null): void
|
||||
{
|
||||
$this->two_factor_secret = $two_factor_secret;
|
||||
$this->two_factor_secret = $twoFactorSecret;
|
||||
}
|
||||
|
||||
public function verifyTwoFactor(string $otp): bool
|
||||
|
|
|
@ -127,15 +127,15 @@ enum SupportedLocales: string
|
|||
$possibleLocales[] = $user->getLocale();
|
||||
}
|
||||
|
||||
$server_params = $request->getServerParams();
|
||||
$browser_locale = Locale::acceptFromHttp($server_params['HTTP_ACCEPT_LANGUAGE'] ?? '');
|
||||
$serverParams = $request->getServerParams();
|
||||
$browserLocale = Locale::acceptFromHttp($serverParams['HTTP_ACCEPT_LANGUAGE'] ?? '');
|
||||
|
||||
if (!empty($browser_locale)) {
|
||||
if (2 === strlen($browser_locale)) {
|
||||
$browser_locale = strtolower($browser_locale) . '_' . strtoupper($browser_locale);
|
||||
if (!empty($browserLocale)) {
|
||||
if (2 === strlen($browserLocale)) {
|
||||
$browserLocale = strtolower($browserLocale) . '_' . strtoupper($browserLocale);
|
||||
}
|
||||
|
||||
$possibleLocales[] = substr($browser_locale, 0, 5) . '.UTF-8';
|
||||
$possibleLocales[] = substr($browserLocale, 0, 5) . '.UTF-8';
|
||||
}
|
||||
|
||||
// Attempt to load from environment variable.
|
||||
|
|
|
@ -32,12 +32,12 @@ abstract class AbstractBuildMenu extends Event
|
|||
/**
|
||||
* Add a single item to the menu.
|
||||
*
|
||||
* @param string $item_id
|
||||
* @param array $item_details
|
||||
* @param string $itemId
|
||||
* @param array $itemDetails
|
||||
*/
|
||||
public function addItem(string $item_id, array $item_details): void
|
||||
public function addItem(string $itemId, array $itemDetails): void
|
||||
{
|
||||
$this->merge([$item_id => $item_details]);
|
||||
$this->merge([$itemId => $itemDetails]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,8 +86,8 @@ abstract class AbstractBuildMenu extends Event
|
|||
return true;
|
||||
}
|
||||
|
||||
public function checkPermission(string|PermissionInterface $permission_name): bool
|
||||
public function checkPermission(string|PermissionInterface $permissionName): bool
|
||||
{
|
||||
return $this->request->getAcl()->isAllowed($permission_name);
|
||||
return $this->request->getAcl()->isAllowed($permissionName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ final class BuildStationMenu extends AbstractBuildMenu
|
|||
return $this->station;
|
||||
}
|
||||
|
||||
public function checkPermission(string|PermissionInterface $permission_name): bool
|
||||
public function checkPermission(string|PermissionInterface $permissionName): bool
|
||||
{
|
||||
return $this->request->getAcl()->isAllowed($permission_name, $this->station->getId());
|
||||
return $this->request->getAcl()->isAllowed($permissionName, $this->station->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,12 +91,12 @@ final class AnnotateNextSong extends Event
|
|||
$this->annotations = array_filter($this->annotations);
|
||||
|
||||
if (!empty($this->annotations)) {
|
||||
$annotations_str = [];
|
||||
foreach ($this->annotations as $annotation_key => $annotation_val) {
|
||||
$annotations_str[] = $annotation_key . '="' . $annotation_val . '"';
|
||||
$annotationsStr = [];
|
||||
foreach ($this->annotations as $annotationKey => $annotationVal) {
|
||||
$annotationsStr[] = $annotationKey . '="' . $annotationVal . '"';
|
||||
}
|
||||
|
||||
return 'annotate:' . implode(',', $annotations_str) . ':' . $this->songPath;
|
||||
return 'annotate:' . implode(',', $annotationsStr) . ':' . $this->songPath;
|
||||
}
|
||||
|
||||
return $this->songPath;
|
||||
|
|
|
@ -20,7 +20,7 @@ final class GenerateRawNowPlaying extends Event
|
|||
public function __construct(
|
||||
private readonly Adapters $adapters,
|
||||
private readonly Station $station,
|
||||
private readonly bool $include_clients = false
|
||||
private readonly bool $includeClients = false
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ final class GenerateRawNowPlaying extends Event
|
|||
|
||||
public function includeClients(): bool
|
||||
{
|
||||
return $this->include_clients;
|
||||
return $this->includeClients;
|
||||
}
|
||||
|
||||
public function getResult(): Result
|
||||
|
|
|
@ -84,25 +84,25 @@ final class Response extends SlimResponse
|
|||
/**
|
||||
* Write a string of file data to the response as if it is a file for download.
|
||||
*
|
||||
* @param string $file_data
|
||||
* @param string $content_type
|
||||
* @param string|null $file_name
|
||||
* @param string $fileData
|
||||
* @param string $contentType
|
||||
* @param string|null $fileName
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function renderStringAsFile(string $file_data, string $content_type, ?string $file_name = null): Response
|
||||
public function renderStringAsFile(string $fileData, string $contentType, ?string $fileName = null): Response
|
||||
{
|
||||
$response = $this->response
|
||||
->withHeader('Pragma', 'public')
|
||||
->withHeader('Expires', '0')
|
||||
->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||
->withHeader('Content-Type', $content_type);
|
||||
->withHeader('Content-Type', $contentType);
|
||||
|
||||
if ($file_name !== null) {
|
||||
$response = $response->withHeader('Content-Disposition', 'attachment; filename=' . $file_name);
|
||||
if ($fileName !== null) {
|
||||
$response = $response->withHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
||||
}
|
||||
|
||||
$response->getBody()->write($file_data);
|
||||
$response->getBody()->write($fileData);
|
||||
|
||||
return new Response($response, $this->streamFactory);
|
||||
}
|
||||
|
|
|
@ -94,11 +94,11 @@ final class ServerRequest extends SlimServerRequest
|
|||
|
||||
/**
|
||||
* @param string $attr
|
||||
* @param string $class_name
|
||||
* @param string $className
|
||||
*
|
||||
* @throws Exception\InvalidRequestAttribute
|
||||
*/
|
||||
private function getAttributeOfClass(string $attr, string $class_name): mixed
|
||||
private function getAttributeOfClass(string $attr, string $className): mixed
|
||||
{
|
||||
$object = $this->serverRequest->getAttribute($attr);
|
||||
|
||||
|
@ -111,12 +111,12 @@ final class ServerRequest extends SlimServerRequest
|
|||
);
|
||||
}
|
||||
|
||||
if (!($object instanceof $class_name)) {
|
||||
if (!($object instanceof $className)) {
|
||||
throw new Exception\InvalidRequestAttribute(
|
||||
sprintf(
|
||||
'Attribute "%s" must be of type "%s".',
|
||||
$attr,
|
||||
$class_name
|
||||
$className
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -33,14 +33,14 @@ final class EnforceSecurity implements MiddlewareInterface
|
|||
*/
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$always_use_ssl = $this->readSettings()->getAlwaysUseSsl();
|
||||
$alwaysUseSsl = $this->readSettings()->getAlwaysUseSsl();
|
||||
|
||||
$internal_api_url = mb_stripos($request->getUri()->getPath(), '/api/internal') === 0;
|
||||
$internalApiUrl = mb_stripos($request->getUri()->getPath(), '/api/internal') === 0;
|
||||
|
||||
$addHstsHeader = false;
|
||||
if ('https' === $request->getUri()->getScheme()) {
|
||||
$addHstsHeader = true;
|
||||
} elseif ($always_use_ssl && !$internal_api_url) {
|
||||
} elseif ($alwaysUseSsl && !$internalApiUrl) {
|
||||
return $this->responseFactory->createResponse(307)
|
||||
->withHeader('Location', (string)$request->getUri()->withScheme('https'));
|
||||
}
|
||||
|
|
|
@ -19,18 +19,18 @@ use Slim\Routing\RouteContext;
|
|||
final class GetStation implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly StationRepository $station_repo
|
||||
private readonly StationRepository $stationRepo
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$route_args = RouteContext::fromRequest($request)->getRoute()?->getArguments();
|
||||
$routeArgs = RouteContext::fromRequest($request)->getRoute()?->getArguments();
|
||||
|
||||
$id = $route_args['station_id'] ?? null;
|
||||
$id = $routeArgs['station_id'] ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
$record = $this->station_repo->findByIdentifier($id);
|
||||
$record = $this->stationRepo->findByIdentifier($id);
|
||||
|
||||
if ($record instanceof Station) {
|
||||
$request = $request->withAttribute(ServerRequest::ATTR_STATION, $record);
|
||||
|
|
|
@ -34,12 +34,12 @@ final class Admin
|
|||
|
||||
$view = $request->getView();
|
||||
|
||||
$active_tab = null;
|
||||
$current_route = RouteContext::fromRequest($request)->getRoute();
|
||||
$activeTab = null;
|
||||
$currentRoute = RouteContext::fromRequest($request)->getRoute();
|
||||
|
||||
if ($current_route instanceof RouteInterface) {
|
||||
$route_parts = explode(':', $current_route->getName() ?? '');
|
||||
$active_tab = $route_parts[1];
|
||||
if ($currentRoute instanceof RouteInterface) {
|
||||
$routeParts = explode(':', $currentRoute->getName() ?? '');
|
||||
$activeTab = $routeParts[1];
|
||||
}
|
||||
|
||||
$view->addData(
|
||||
|
@ -54,7 +54,7 @@ final class Admin
|
|||
$view->render(
|
||||
'admin/sidebar',
|
||||
[
|
||||
'active_tab' => $active_tab,
|
||||
'active_tab' => $activeTab,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
|
|
@ -41,11 +41,11 @@ final class Stations
|
|||
$event = new Event\BuildStationMenu($station, $request, $settings);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
||||
$active_tab = null;
|
||||
$current_route = RouteContext::fromRequest($request)->getRoute();
|
||||
if ($current_route instanceof RouteInterface) {
|
||||
$route_parts = explode(':', $current_route->getName() ?? '');
|
||||
$active_tab = $route_parts[1];
|
||||
$activeTab = null;
|
||||
$currentRoute = RouteContext::fromRequest($request)->getRoute();
|
||||
if ($currentRoute instanceof RouteInterface) {
|
||||
$routeParts = explode(':', $currentRoute->getName() ?? '');
|
||||
$activeTab = $routeParts[1];
|
||||
}
|
||||
|
||||
$view->getSections()->set(
|
||||
|
@ -54,7 +54,7 @@ final class Stations
|
|||
'stations/sidebar',
|
||||
[
|
||||
'menu' => $event->getFilteredMenu(),
|
||||
'active' => $active_tab,
|
||||
'active' => $activeTab,
|
||||
]
|
||||
),
|
||||
);
|
||||
|
|
|
@ -18,16 +18,16 @@ final class Permissions
|
|||
{
|
||||
public function __construct(
|
||||
private readonly string|PermissionInterface $action,
|
||||
private readonly bool $use_station = false
|
||||
private readonly bool $useStation = false
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
if ($this->use_station) {
|
||||
$station_id = $request->getStation()->getId();
|
||||
if ($this->useStation) {
|
||||
$stationId = $request->getStation()->getId();
|
||||
} else {
|
||||
$station_id = null;
|
||||
$stationId = null;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -37,7 +37,7 @@ final class Permissions
|
|||
}
|
||||
|
||||
$acl = $request->getAcl();
|
||||
if (!$acl->userAllowed($user, $this->action, $station_id)) {
|
||||
if (!$acl->userAllowed($user, $this->action, $stationId)) {
|
||||
throw new PermissionDeniedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,16 +14,16 @@ use Psr\Http\Server\RequestHandlerInterface;
|
|||
final class RateLimit
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $rl_group = 'default',
|
||||
private readonly int $rl_interval = 5,
|
||||
private readonly int $rl_limit = 2
|
||||
private readonly string $rlGroup = 'default',
|
||||
private readonly int $rlInterval = 5,
|
||||
private readonly int $rlLimit = 2
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$rateLimit = $request->getRateLimit();
|
||||
$rateLimit->checkRequestRateLimit($request, $this->rl_group, $this->rl_interval, $this->rl_limit);
|
||||
$rateLimit->checkRequestRateLimit($request, $this->rlGroup, $this->rlInterval, $this->rlLimit);
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
|
|
@ -86,22 +86,22 @@ final class DoctrineEntityNormalizer extends AbstractObjectNormalizer
|
|||
$context[self::ASSOCIATION_MAPPINGS] = [];
|
||||
|
||||
if ($context[self::CLASS_METADATA]->associationMappings) {
|
||||
foreach ($context[self::CLASS_METADATA]->associationMappings as $mapping_name => $mapping_info) {
|
||||
$entity = $mapping_info['targetEntity'];
|
||||
foreach ($context[self::CLASS_METADATA]->associationMappings as $mappingName => $mappingInfo) {
|
||||
$entity = $mappingInfo['targetEntity'];
|
||||
|
||||
if (isset($mapping_info['joinTable'])) {
|
||||
$context[self::ASSOCIATION_MAPPINGS][$mapping_info['fieldName']] = [
|
||||
if (isset($mappingInfo['joinTable'])) {
|
||||
$context[self::ASSOCIATION_MAPPINGS][$mappingInfo['fieldName']] = [
|
||||
'type' => 'many',
|
||||
'entity' => $entity,
|
||||
'is_owning_side' => ($mapping_info['isOwningSide'] == 1),
|
||||
'is_owning_side' => ($mappingInfo['isOwningSide'] == 1),
|
||||
];
|
||||
} elseif (isset($mapping_info['joinColumns'])) {
|
||||
foreach ($mapping_info['joinColumns'] as $col) {
|
||||
$col_name = $col['name'];
|
||||
$col_name = $context[self::CLASS_METADATA]->fieldNames[$col_name] ?? $col_name;
|
||||
} elseif (isset($mappingInfo['joinColumns'])) {
|
||||
foreach ($mappingInfo['joinColumns'] as $col) {
|
||||
$colName = $col['name'];
|
||||
$colName = $context[self::CLASS_METADATA]->fieldNames[$colName] ?? $colName;
|
||||
|
||||
$context[self::ASSOCIATION_MAPPINGS][$mapping_name] = [
|
||||
'name' => $col_name,
|
||||
$context[self::ASSOCIATION_MAPPINGS][$mappingName] = [
|
||||
'name' => $colName,
|
||||
'type' => 'one',
|
||||
'entity' => $entity,
|
||||
];
|
||||
|
@ -257,15 +257,15 @@ final class DoctrineEntityNormalizer extends AbstractObjectNormalizer
|
|||
private function getProperty(object $entity, string $key): mixed
|
||||
{
|
||||
// Default to "getStatus", "getConfig", etc...
|
||||
$getter_method = $this->getMethodName($key, 'get');
|
||||
if (method_exists($entity, $getter_method)) {
|
||||
return $entity->{$getter_method}();
|
||||
$getterMethod = $this->getMethodName($key, 'get');
|
||||
if (method_exists($entity, $getterMethod)) {
|
||||
return $entity->{$getterMethod}();
|
||||
}
|
||||
|
||||
// but also allow "isEnabled" instead of "getIsEnabled"
|
||||
$raw_method = $this->getMethodName($key);
|
||||
if (method_exists($entity, $raw_method)) {
|
||||
return $entity->{$raw_method}();
|
||||
$rawMethod = $this->getMethodName($key);
|
||||
if (method_exists($entity, $rawMethod)) {
|
||||
return $entity->{$rawMethod}();
|
||||
}
|
||||
|
||||
throw new NoGetterAvailableException(sprintf('No getter is available for property %s.', $key));
|
||||
|
@ -303,8 +303,8 @@ final class DoctrineEntityNormalizer extends AbstractObjectNormalizer
|
|||
} else {
|
||||
/** @var class-string $entity */
|
||||
$entity = $mapping['entity'];
|
||||
if (($field_item = $this->em->find($entity, $value)) instanceof $entity) {
|
||||
$this->setProperty($object, $attribute, $field_item);
|
||||
if (($fieldItem = $this->em->find($entity, $value)) instanceof $entity) {
|
||||
$this->setProperty($object, $attribute, $fieldItem);
|
||||
}
|
||||
}
|
||||
} elseif ($mapping['is_owning_side']) {
|
||||
|
@ -314,13 +314,13 @@ final class DoctrineEntityNormalizer extends AbstractObjectNormalizer
|
|||
$collection->clear();
|
||||
|
||||
if ($value) {
|
||||
foreach ((array)$value as $field_id) {
|
||||
foreach ((array)$value as $fieldId) {
|
||||
/** @var class-string $entity */
|
||||
$entity = $mapping['entity'];
|
||||
|
||||
$field_item = $this->em->find($entity, $field_id);
|
||||
if ($field_item instanceof $entity) {
|
||||
$collection->add($field_item);
|
||||
$fieldItem = $this->em->find($entity, $fieldId);
|
||||
if ($fieldItem instanceof $entity) {
|
||||
$collection->add($fieldItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ final class Plugins
|
|||
->depth('== 0')
|
||||
->in($dir);
|
||||
|
||||
foreach ($plugins as $plugin_dir) {
|
||||
/** @var SplFileInfo $plugin_dir */
|
||||
$plugin_prefix = $plugin_dir->getRelativePathname();
|
||||
$plugin_namespace = 'Plugin\\' . $this->inflector->classify($plugin_prefix) . '\\';
|
||||
foreach ($plugins as $pluginDir) {
|
||||
/** @var SplFileInfo $pluginDir */
|
||||
$pluginPrefix = $pluginDir->getRelativePathname();
|
||||
$pluginNamespace = 'Plugin\\' . $this->inflector->classify($pluginPrefix) . '\\';
|
||||
|
||||
$this->plugins[$plugin_prefix] = [
|
||||
'namespace' => $plugin_namespace,
|
||||
'path' => $plugin_dir->getPathname(),
|
||||
$this->plugins[$pluginPrefix] = [
|
||||
'namespace' => $pluginNamespace,
|
||||
'path' => $pluginDir->getPathname(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ final class Plugins
|
|||
public function registerServices(array $diDefinitions = []): array
|
||||
{
|
||||
foreach ($this->plugins as $plugin) {
|
||||
$plugin_path = $plugin['path'];
|
||||
$pluginPath = $plugin['path'];
|
||||
|
||||
if (is_file($plugin_path . '/services.php')) {
|
||||
$services = include $plugin_path . '/services.php';
|
||||
if (is_file($pluginPath . '/services.php')) {
|
||||
$services = include $pluginPath . '/services.php';
|
||||
$diDefinitions = array_merge($diDefinitions, $services);
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ final class Plugins
|
|||
public function registerEvents(CallableEventDispatcherInterface $dispatcher): void
|
||||
{
|
||||
foreach ($this->plugins as $plugin) {
|
||||
$plugin_path = $plugin['path'];
|
||||
$pluginPath = $plugin['path'];
|
||||
|
||||
if (file_exists($plugin_path . '/events.php')) {
|
||||
call_user_func(include($plugin_path . '/events.php'), $dispatcher);
|
||||
if (file_exists($pluginPath . '/events.php')) {
|
||||
call_user_func(include($pluginPath . '/events.php'), $dispatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,10 +104,10 @@ abstract class AbstractLocalAdapter
|
|||
return true;
|
||||
}
|
||||
|
||||
$program_name = $this->getSupervisorFullName($station);
|
||||
$programName = $this->getSupervisorFullName($station);
|
||||
|
||||
try {
|
||||
return $this->supervisor->getProcess($program_name)->isRunning();
|
||||
return $this->supervisor->getProcess($programName)->isRunning();
|
||||
} catch (Fault\BadNameException) {
|
||||
return false;
|
||||
}
|
||||
|
@ -185,16 +185,16 @@ abstract class AbstractLocalAdapter
|
|||
public function stop(Station $station): void
|
||||
{
|
||||
if ($this->hasCommand($station)) {
|
||||
$program_name = $this->getSupervisorFullName($station);
|
||||
$programName = $this->getSupervisorFullName($station);
|
||||
|
||||
try {
|
||||
$this->supervisor->stopProcess($program_name);
|
||||
$this->supervisor->stopProcess($programName);
|
||||
$this->logger->info(
|
||||
'Adapter "' . static::class . '" stopped.',
|
||||
['station_id' => $station->getId(), 'station_name' => $station->getName()]
|
||||
);
|
||||
} catch (SupervisorLibException $e) {
|
||||
$this->handleSupervisorException($e, $program_name, $station);
|
||||
$this->handleSupervisorException($e, $programName, $station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,16 +210,16 @@ abstract class AbstractLocalAdapter
|
|||
public function start(Station $station): void
|
||||
{
|
||||
if ($this->hasCommand($station)) {
|
||||
$program_name = $this->getSupervisorFullName($station);
|
||||
$programName = $this->getSupervisorFullName($station);
|
||||
|
||||
try {
|
||||
$this->supervisor->startProcess($program_name);
|
||||
$this->supervisor->startProcess($programName);
|
||||
$this->logger->info(
|
||||
'Adapter "' . static::class . '" started.',
|
||||
['station_id' => $station->getId(), 'station_name' => $station->getName()]
|
||||
);
|
||||
} catch (SupervisorLibException $e) {
|
||||
$this->handleSupervisorException($e, $program_name, $station);
|
||||
$this->handleSupervisorException($e, $programName, $station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,17 +228,17 @@ abstract class AbstractLocalAdapter
|
|||
* Internal handling of any Supervisor-related exception, to add richer data to it.
|
||||
*
|
||||
* @param SupervisorLibException $e
|
||||
* @param string $program_name
|
||||
* @param string $programName
|
||||
* @param Station $station
|
||||
*
|
||||
* @throws SupervisorException
|
||||
*/
|
||||
protected function handleSupervisorException(
|
||||
SupervisorLibException $e,
|
||||
string $program_name,
|
||||
string $programName,
|
||||
Station $station
|
||||
): void {
|
||||
$eNew = SupervisorException::fromSupervisorLibException($e, $program_name);
|
||||
$eNew = SupervisorException::fromSupervisorLibException($e, $programName);
|
||||
$eNew->addLoggingContext('station_id', $station->getId());
|
||||
$eNew->addLoggingContext('station_name', $station->getName());
|
||||
|
||||
|
@ -252,11 +252,11 @@ abstract class AbstractLocalAdapter
|
|||
*/
|
||||
public function getLogPath(Station $station): string
|
||||
{
|
||||
$config_dir = $station->getRadioConfigDir();
|
||||
$configDir = $station->getRadioConfigDir();
|
||||
|
||||
$class_parts = explode('\\', static::class);
|
||||
$class_name = array_pop($class_parts);
|
||||
$classParts = explode('\\', static::class);
|
||||
$className = array_pop($classParts);
|
||||
|
||||
return $config_dir . '/' . strtolower($class_name) . '.log';
|
||||
return $configDir . '/' . strtolower($className) . '.log';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,12 +59,12 @@ final class Adapters
|
|||
|
||||
public function getRemoteAdapter(StationRemote $remote): Remote\AbstractRemote
|
||||
{
|
||||
$class_name = $remote->getType()->getClass();
|
||||
if ($this->di->has($class_name)) {
|
||||
return $this->di->get($class_name);
|
||||
$className = $remote->getType()->getClass();
|
||||
if ($this->di->has($className)) {
|
||||
return $this->di->get($className);
|
||||
}
|
||||
|
||||
throw new NotFoundException('Adapter not found: ' . $class_name);
|
||||
throw new NotFoundException('Adapter not found: ' . $className);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,13 +94,13 @@ final class Adapters
|
|||
if ($checkInstalled) {
|
||||
return array_filter(
|
||||
$adapters,
|
||||
function ($adapter_info) {
|
||||
if (null === $adapter_info['class']) {
|
||||
function ($adapterInfo) {
|
||||
if (null === $adapterInfo['class']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @var AbstractLocalAdapter $adapter */
|
||||
$adapter = $this->di->get($adapter_info['class']);
|
||||
$adapter = $this->di->get($adapterInfo['class']);
|
||||
return $adapter->isInstalled();
|
||||
}
|
||||
);
|
||||
|
|
|
@ -108,17 +108,17 @@ final class Annotations implements EventSubscriberInterface
|
|||
isset($annotationsRaw['liq_cue_out'])
|
||||
&& $annotationsRaw['liq_cue_out'] < 0
|
||||
) {
|
||||
$cue_out = abs($annotationsRaw['liq_cue_out']);
|
||||
$cueOut = abs($annotationsRaw['liq_cue_out']);
|
||||
|
||||
if (0.0 === $cue_out) {
|
||||
if (0.0 === $cueOut) {
|
||||
unset($annotationsRaw['liq_cue_out']);
|
||||
}
|
||||
|
||||
if (isset($annotationsRaw['duration'])) {
|
||||
if ($cue_out > $annotationsRaw['duration']) {
|
||||
if ($cueOut > $annotationsRaw['duration']) {
|
||||
unset($annotationsRaw['liq_cue_out']);
|
||||
} else {
|
||||
$annotationsRaw['liq_cue_out'] = max(0, $annotationsRaw['duration'] - $cue_out);
|
||||
$annotationsRaw['liq_cue_out'] = max(0, $annotationsRaw['duration'] - $cueOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,18 +126,18 @@ final class Scheduler
|
|||
StationPlaylist $playlist,
|
||||
CarbonInterface $now
|
||||
): bool {
|
||||
$current_minute = $now->minute;
|
||||
$target_minute = $playlist->getPlayPerHourMinute();
|
||||
$currentMinute = $now->minute;
|
||||
$targetMinute = $playlist->getPlayPerHourMinute();
|
||||
|
||||
if ($current_minute < $target_minute) {
|
||||
$target_time = $now->subHour()->minute($target_minute);
|
||||
if ($currentMinute < $targetMinute) {
|
||||
$targetTime = $now->subHour()->minute($targetMinute);
|
||||
} else {
|
||||
$target_time = $now->minute($target_minute);
|
||||
$targetTime = $now->minute($targetMinute);
|
||||
}
|
||||
|
||||
$playlist_diff = $target_time->diffInMinutes($now, false);
|
||||
$playlistDiff = $targetTime->diffInMinutes($now, false);
|
||||
|
||||
if ($playlist_diff < 0 || $playlist_diff > 15) {
|
||||
if ($playlistDiff < 0 || $playlistDiff > 15) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,23 +53,23 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
}
|
||||
|
||||
// Default to frontend port + 5
|
||||
$frontend_config = $station->getFrontendConfig();
|
||||
$frontend_port = $frontend_config->getPort() ?? (8000 + (($station->getId() - 1) * 10));
|
||||
$frontendConfig = $station->getFrontendConfig();
|
||||
$frontendPort = $frontendConfig->getPort() ?? (8000 + (($station->getId() - 1) * 10));
|
||||
|
||||
return $frontend_port + 5;
|
||||
return $frontendPort + 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the specified remote command on LiquidSoap via the telnet API.
|
||||
*
|
||||
* @param Station $station
|
||||
* @param string $command_str
|
||||
* @param string $commandStr
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function command(Station $station, string $command_str): array
|
||||
public function command(Station $station, string $commandStr): array
|
||||
{
|
||||
$socketPath = 'unix://' . $station->getRadioConfigDir() . '/liquidsoap.sock';
|
||||
|
||||
|
@ -84,7 +84,7 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
throw new Exception('Telnet failure: ' . $errstr . ' (' . $errno . ')');
|
||||
}
|
||||
|
||||
fwrite($fp, str_replace(["\\'", '&'], ["'", '&'], urldecode($command_str)) . "\nquit\n");
|
||||
fwrite($fp, str_replace(["\\'", '&'], ["'", '&'], urldecode($commandStr)) . "\nquit\n");
|
||||
|
||||
$response = [];
|
||||
while (!feof($fp)) {
|
||||
|
@ -102,8 +102,8 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
public function getCommand(Station $station): ?string
|
||||
{
|
||||
if ($binary = $this->getBinary()) {
|
||||
$config_path = $station->getRadioConfigDir() . '/liquidsoap.liq';
|
||||
return $binary . ' ' . $config_path;
|
||||
$configPath = $station->getRadioConfigDir() . '/liquidsoap.liq';
|
||||
return $binary . ' ' . $configPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -161,11 +161,11 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
public function enqueue(
|
||||
Station $station,
|
||||
LiquidsoapQueues $queue,
|
||||
string $music_file
|
||||
string $musicFile
|
||||
): array {
|
||||
return $this->command(
|
||||
$station,
|
||||
sprintf('%s.push %s', $queue->value, $music_file)
|
||||
sprintf('%s.push %s', $queue->value, $musicFile)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -205,13 +205,13 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
*/
|
||||
public function disconnectStreamer(Station $station): array
|
||||
{
|
||||
$current_streamer = $station->getCurrentStreamer();
|
||||
$disconnect_timeout = $station->getDisconnectDeactivateStreamer();
|
||||
$currentStreamer = $station->getCurrentStreamer();
|
||||
$disconnectTimeout = $station->getDisconnectDeactivateStreamer();
|
||||
|
||||
if ($current_streamer instanceof StationStreamer && $disconnect_timeout > 0) {
|
||||
$current_streamer->deactivateFor($disconnect_timeout);
|
||||
if ($currentStreamer instanceof StationStreamer && $disconnectTimeout > 0) {
|
||||
$currentStreamer->deactivateFor($disconnectTimeout);
|
||||
|
||||
$this->em->persist($current_streamer);
|
||||
$this->em->persist($currentStreamer);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
|
@ -221,13 +221,13 @@ final class Liquidsoap extends AbstractLocalAdapter
|
|||
);
|
||||
}
|
||||
|
||||
public function getWebStreamingUrl(Station $station, UriInterface $base_url): UriInterface
|
||||
public function getWebStreamingUrl(Station $station, UriInterface $baseUrl): UriInterface
|
||||
{
|
||||
$djMount = $station->getBackendConfig()->getDjMountPoint();
|
||||
|
||||
return $base_url
|
||||
return $baseUrl
|
||||
->withScheme('wss')
|
||||
->withPath($base_url->getPath() . CustomUrls::getWebDjUrl($station) . $djMount);
|
||||
->withPath($baseUrl->getPath() . CustomUrls::getWebDjUrl($station) . $djMount);
|
||||
}
|
||||
|
||||
public function verifyConfig(string $config): void
|
||||
|
|
|
@ -437,10 +437,10 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
$event->appendLines($playlistConfigLines);
|
||||
|
||||
foreach ($scheduleItems as $scheduleItem) {
|
||||
$play_time = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
$playTime = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
|
||||
$schedule_timing = '({ ' . $play_time . ' }, ' . $playlistVarName . ')';
|
||||
$scheduleSwitchesRemoteUrl[] = $schedule_timing;
|
||||
$scheduleTiming = '({ ' . $playTime . ' }, ' . $playlistVarName . ')';
|
||||
$scheduleSwitchesRemoteUrl[] = $scheduleTiming;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -463,14 +463,14 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
case PlaylistTypes::Standard:
|
||||
if ($scheduleItems->count() > 0) {
|
||||
foreach ($scheduleItems as $scheduleItem) {
|
||||
$play_time = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
$playTime = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
|
||||
$schedule_timing = '({ ' . $play_time . ' }, ' . $playlistVarName . ')';
|
||||
$scheduleTiming = '({ ' . $playTime . ' }, ' . $playlistVarName . ')';
|
||||
|
||||
if ($playlist->backendInterruptOtherSongs()) {
|
||||
$scheduleSwitchesInterrupting[] = $schedule_timing;
|
||||
$scheduleSwitchesInterrupting[] = $scheduleTiming;
|
||||
} else {
|
||||
$scheduleSwitches[] = $schedule_timing;
|
||||
$scheduleSwitches[] = $scheduleTiming;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -493,14 +493,14 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
if ($scheduleItems->count() > 0) {
|
||||
foreach ($scheduleItems as $scheduleItem) {
|
||||
$play_time = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
$playTime = $this->getScheduledPlaylistPlayTime($event, $scheduleItem);
|
||||
|
||||
$schedule_timing = '({ ' . $play_time . ' }, ' . $playlistScheduleVar . ')';
|
||||
$scheduleTiming = '({ ' . $playTime . ' }, ' . $playlistScheduleVar . ')';
|
||||
|
||||
if ($playlist->backendInterruptOtherSongs()) {
|
||||
$scheduleSwitchesInterrupting[] = $schedule_timing;
|
||||
$scheduleSwitchesInterrupting[] = $scheduleTiming;
|
||||
} else {
|
||||
$scheduleSwitches[] = $schedule_timing;
|
||||
$scheduleSwitches[] = $scheduleTiming;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -516,21 +516,21 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
$playTime = '(' . $minutePlayTime . ') and ('
|
||||
. $this->getScheduledPlaylistPlayTime($event, $scheduleItem) . ')';
|
||||
|
||||
$schedule_timing = '({ ' . $playTime . ' }, ' . $playlistVarName . ')';
|
||||
$scheduleTiming = '({ ' . $playTime . ' }, ' . $playlistVarName . ')';
|
||||
|
||||
if ($playlist->backendInterruptOtherSongs()) {
|
||||
$scheduleSwitchesInterrupting[] = $schedule_timing;
|
||||
$scheduleSwitchesInterrupting[] = $scheduleTiming;
|
||||
} else {
|
||||
$scheduleSwitches[] = $schedule_timing;
|
||||
$scheduleSwitches[] = $scheduleTiming;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$schedule_timing = '({ ' . $minutePlayTime . ' }, ' . $playlistVarName . ')';
|
||||
$scheduleTiming = '({ ' . $minutePlayTime . ' }, ' . $playlistVarName . ')';
|
||||
|
||||
if ($playlist->backendInterruptOtherSongs()) {
|
||||
$scheduleSwitchesInterrupting[] = $schedule_timing;
|
||||
$scheduleSwitchesInterrupting[] = $scheduleTiming;
|
||||
} else {
|
||||
$scheduleSwitches[] = $schedule_timing;
|
||||
$scheduleSwitches[] = $scheduleTiming;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -722,51 +722,51 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
WriteLiquidsoapConfiguration $event,
|
||||
StationSchedule $playlistSchedule
|
||||
): string {
|
||||
$start_time = $playlistSchedule->getStartTime();
|
||||
$end_time = $playlistSchedule->getEndTime();
|
||||
$startTime = $playlistSchedule->getStartTime();
|
||||
$endTime = $playlistSchedule->getEndTime();
|
||||
|
||||
// Handle multi-day playlists.
|
||||
if ($start_time > $end_time) {
|
||||
$play_times = [
|
||||
self::formatTimeCode($start_time) . '-23h59m59s',
|
||||
'00h00m-' . self::formatTimeCode($end_time),
|
||||
if ($startTime > $endTime) {
|
||||
$playTimes = [
|
||||
self::formatTimeCode($startTime) . '-23h59m59s',
|
||||
'00h00m-' . self::formatTimeCode($endTime),
|
||||
];
|
||||
|
||||
$playlist_schedule_days = $playlistSchedule->getDays();
|
||||
if (!empty($playlist_schedule_days) && count($playlist_schedule_days) < 7) {
|
||||
$current_play_days = [];
|
||||
$next_play_days = [];
|
||||
$playlistScheduleDays = $playlistSchedule->getDays();
|
||||
if (!empty($playlistScheduleDays) && count($playlistScheduleDays) < 7) {
|
||||
$currentPlayDays = [];
|
||||
$nextPlayDays = [];
|
||||
|
||||
foreach ($playlist_schedule_days as $day) {
|
||||
$current_play_days[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
foreach ($playlistScheduleDays as $day) {
|
||||
$currentPlayDays[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
|
||||
$day++;
|
||||
if ($day > 7) {
|
||||
$day = 1;
|
||||
}
|
||||
$next_play_days[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
$nextPlayDays[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
}
|
||||
|
||||
$play_times[0] = '(' . implode(' or ', $current_play_days) . ') and ' . $play_times[0];
|
||||
$play_times[1] = '(' . implode(' or ', $next_play_days) . ') and ' . $play_times[1];
|
||||
$playTimes[0] = '(' . implode(' or ', $currentPlayDays) . ') and ' . $playTimes[0];
|
||||
$playTimes[1] = '(' . implode(' or ', $nextPlayDays) . ') and ' . $playTimes[1];
|
||||
}
|
||||
|
||||
return '(' . implode(') or (', $play_times) . ')';
|
||||
return '(' . implode(') or (', $playTimes) . ')';
|
||||
}
|
||||
|
||||
// Handle once-per-day playlists.
|
||||
$play_time = ($start_time === $end_time)
|
||||
? self::formatTimeCode($start_time)
|
||||
: self::formatTimeCode($start_time) . '-' . self::formatTimeCode($end_time);
|
||||
$playTime = ($startTime === $endTime)
|
||||
? self::formatTimeCode($startTime)
|
||||
: self::formatTimeCode($startTime) . '-' . self::formatTimeCode($endTime);
|
||||
|
||||
$playlist_schedule_days = $playlistSchedule->getDays();
|
||||
if (!empty($playlist_schedule_days) && count($playlist_schedule_days) < 7) {
|
||||
$play_days = [];
|
||||
$playlistScheduleDays = $playlistSchedule->getDays();
|
||||
if (!empty($playlistScheduleDays) && count($playlistScheduleDays) < 7) {
|
||||
$playDays = [];
|
||||
|
||||
foreach ($playlist_schedule_days as $day) {
|
||||
$play_days[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
foreach ($playlistScheduleDays as $day) {
|
||||
$playDays[] = (($day === 7) ? '0' : $day) . 'w';
|
||||
}
|
||||
$play_time = '(' . implode(' or ', $play_days) . ') and ' . $play_time;
|
||||
$playTime = '(' . implode(' or ', $playDays) . ') and ' . $playTime;
|
||||
}
|
||||
|
||||
// Handle start-date and end-date boundaries.
|
||||
|
@ -814,10 +814,10 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
$customFunctionBody[] = 'end';
|
||||
$event->appendLines($customFunctionBody);
|
||||
|
||||
$play_time = $scheduleMethod . '() and ' . $play_time;
|
||||
$playTime = $scheduleMethod . '() and ' . $playTime;
|
||||
}
|
||||
|
||||
return $play_time;
|
||||
return $playTime;
|
||||
}
|
||||
|
||||
public function writeCrossfadeConfiguration(WriteLiquidsoapConfiguration $event): void
|
||||
|
@ -876,7 +876,7 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$settings = $station->getBackendConfig();
|
||||
$charset = $settings->getCharset();
|
||||
$dj_mount = $settings->getDjMountPoint();
|
||||
$djMount = $settings->getDjMountPoint();
|
||||
$recordLiveStreams = $settings->recordStreams();
|
||||
|
||||
$event->appendBlock(
|
||||
|
@ -936,8 +936,8 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
LIQ
|
||||
);
|
||||
|
||||
$harbor_params = [
|
||||
'"' . self::cleanUpString($dj_mount) . '"',
|
||||
$harborParams = [
|
||||
'"' . self::cleanUpString($djMount) . '"',
|
||||
'id = "input_streamer"',
|
||||
'port = ' . $this->liquidsoap->getStreamPort($station),
|
||||
'auth = dj_auth',
|
||||
|
@ -950,11 +950,11 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$djBuffer = $settings->getDjBuffer();
|
||||
if (0 !== $djBuffer) {
|
||||
$harbor_params[] = 'buffer = ' . self::toFloat($djBuffer);
|
||||
$harbor_params[] = 'max = ' . self::toFloat(max($djBuffer + 5, 10));
|
||||
$harborParams[] = 'buffer = ' . self::toFloat($djBuffer);
|
||||
$harborParams[] = 'max = ' . self::toFloat(max($djBuffer + 5, 10));
|
||||
}
|
||||
|
||||
$harborParams = implode(', ', $harbor_params);
|
||||
$harborParams = implode(', ', $harborParams);
|
||||
|
||||
$event->appendBlock(
|
||||
<<<LIQ
|
||||
|
@ -1144,24 +1144,24 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$ls_config = [
|
||||
$lsConfig = [
|
||||
'# Local Broadcasts',
|
||||
];
|
||||
|
||||
// Configure the outbound broadcast.
|
||||
$i = 0;
|
||||
foreach ($station->getMounts() as $mount_row) {
|
||||
foreach ($station->getMounts() as $mountRow) {
|
||||
$i++;
|
||||
|
||||
/** @var StationMount $mount_row */
|
||||
if (!$mount_row->getEnableAutodj()) {
|
||||
/** @var StationMount $mountRow */
|
||||
if (!$mountRow->getEnableAutodj()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ls_config[] = $this->getOutputString($station, $mount_row, 'local_', $i);
|
||||
$lsConfig[] = $this->getOutputString($station, $mountRow, 'local_', $i);
|
||||
}
|
||||
|
||||
$event->appendLines($ls_config);
|
||||
$event->appendLines($lsConfig);
|
||||
}
|
||||
|
||||
public function writeHlsBroadcastConfiguration(WriteLiquidsoapConfiguration $event): void
|
||||
|
@ -1260,21 +1260,21 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
$charset = $station->getBackendConfig()->getCharset();
|
||||
|
||||
$format = $mount->getAutodjFormat() ?? StreamFormats::default();
|
||||
$output_format = $this->getOutputFormatString(
|
||||
$outputFormat = $this->getOutputFormatString(
|
||||
$format,
|
||||
$mount->getAutodjBitrate() ?? 128
|
||||
);
|
||||
|
||||
$output_params = [];
|
||||
$output_params[] = $output_format;
|
||||
$output_params[] = 'id="' . $idPrefix . $id . '"';
|
||||
$outputParams = [];
|
||||
$outputParams[] = $outputFormat;
|
||||
$outputParams[] = 'id="' . $idPrefix . $id . '"';
|
||||
|
||||
$output_params[] = 'host = "' . self::cleanUpString($mount->getAutodjHost()) . '"';
|
||||
$output_params[] = 'port = ' . (int)$mount->getAutodjPort();
|
||||
$outputParams[] = 'host = "' . self::cleanUpString($mount->getAutodjHost()) . '"';
|
||||
$outputParams[] = 'port = ' . (int)$mount->getAutodjPort();
|
||||
|
||||
$username = $mount->getAutodjUsername();
|
||||
if (!empty($username)) {
|
||||
$output_params[] = 'user = "' . self::cleanUpString($username) . '"';
|
||||
$outputParams[] = 'user = "' . self::cleanUpString($username) . '"';
|
||||
}
|
||||
|
||||
$password = self::cleanUpString($mount->getAutodjPassword());
|
||||
|
@ -1284,46 +1284,46 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
$password .= ':#' . $id;
|
||||
}
|
||||
|
||||
$output_params[] = 'password = "' . $password . '"';
|
||||
$outputParams[] = 'password = "' . $password . '"';
|
||||
|
||||
$protocol = $mount->getAutodjProtocol();
|
||||
if (!empty($mount->getAutodjMount())) {
|
||||
if (StreamProtocols::Icy === $protocol) {
|
||||
$output_params[] = 'icy_id = ' . $id;
|
||||
$outputParams[] = 'icy_id = ' . $id;
|
||||
} else {
|
||||
$output_params[] = 'mount = "' . self::cleanUpString($mount->getAutodjMount()) . '"';
|
||||
$outputParams[] = 'mount = "' . self::cleanUpString($mount->getAutodjMount()) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
$output_params[] = 'name = "' . self::cleanUpString($station->getName()) . '"';
|
||||
$outputParams[] = 'name = "' . self::cleanUpString($station->getName()) . '"';
|
||||
|
||||
if (!$mount->getIsShoutcast()) {
|
||||
$output_params[] = 'description = "' . self::cleanUpString($station->getDescription()) . '"';
|
||||
$outputParams[] = 'description = "' . self::cleanUpString($station->getDescription()) . '"';
|
||||
}
|
||||
$output_params[] = 'genre = "' . self::cleanUpString($station->getGenre()) . '"';
|
||||
$outputParams[] = 'genre = "' . self::cleanUpString($station->getGenre()) . '"';
|
||||
|
||||
if (!empty($station->getUrl())) {
|
||||
$output_params[] = 'url = "' . self::cleanUpString($station->getUrl()) . '"';
|
||||
$outputParams[] = 'url = "' . self::cleanUpString($station->getUrl()) . '"';
|
||||
}
|
||||
|
||||
$output_params[] = 'public = ' . ($mount->getIsPublic() ? 'true' : 'false');
|
||||
$output_params[] = 'encoding = "' . $charset . '"';
|
||||
$outputParams[] = 'public = ' . ($mount->getIsPublic() ? 'true' : 'false');
|
||||
$outputParams[] = 'encoding = "' . $charset . '"';
|
||||
|
||||
if (!$mount->getIsShoutcast() && null !== $protocol) {
|
||||
$output_params[] = 'protocol="' . $protocol->value . '"';
|
||||
$outputParams[] = 'protocol="' . $protocol->value . '"';
|
||||
}
|
||||
|
||||
if ($format->sendIcyMetadata()) {
|
||||
$output_params[] = 'send_icy_metadata="true"';
|
||||
$outputParams[] = 'send_icy_metadata="true"';
|
||||
}
|
||||
|
||||
$output_params[] = 'radio';
|
||||
$outputParams[] = 'radio';
|
||||
|
||||
$outputCommand = ($mount->getIsShoutcast())
|
||||
? 'output.shoutcast'
|
||||
: 'output.icecast';
|
||||
|
||||
return $outputCommand . '(' . implode(', ', $output_params) . ')';
|
||||
return $outputCommand . '(' . implode(', ', $outputParams) . ')';
|
||||
}
|
||||
|
||||
private function getOutputFormatString(StreamFormats $format, int $bitrate = 128): string
|
||||
|
@ -1355,24 +1355,24 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
{
|
||||
$station = $event->getStation();
|
||||
|
||||
$ls_config = [
|
||||
$lsConfig = [
|
||||
'# Remote Relays',
|
||||
];
|
||||
|
||||
// Set up broadcast to remote relays.
|
||||
$i = 0;
|
||||
foreach ($station->getRemotes() as $remote_row) {
|
||||
foreach ($station->getRemotes() as $remoteRow) {
|
||||
$i++;
|
||||
|
||||
/** @var StationRemote $remote_row */
|
||||
if (!$remote_row->getEnableAutodj()) {
|
||||
/** @var StationRemote $remoteRow */
|
||||
if (!$remoteRow->getEnableAutodj()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ls_config[] = $this->getOutputString($station, $remote_row, 'relay_', $i);
|
||||
$lsConfig[] = $this->getOutputString($station, $remoteRow, 'relay_', $i);
|
||||
}
|
||||
|
||||
$event->appendLines($ls_config);
|
||||
$event->appendLines($lsConfig);
|
||||
}
|
||||
|
||||
public function writePostBroadcastConfiguration(WriteLiquidsoapConfiguration $event): void
|
||||
|
@ -1391,10 +1391,10 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
return number_format((float)$number, $decimals, '.', '');
|
||||
}
|
||||
|
||||
public static function formatTimeCode(int $time_code): string
|
||||
public static function formatTimeCode(int $timeCode): string
|
||||
{
|
||||
$hours = floor($time_code / 100);
|
||||
$mins = $time_code % 100;
|
||||
$hours = floor($timeCode / 100);
|
||||
$mins = $timeCode % 100;
|
||||
|
||||
return $hours . 'h' . $mins . 'm';
|
||||
}
|
||||
|
|
|
@ -174,8 +174,8 @@ final class Configuration
|
|||
}
|
||||
|
||||
// Write config contents
|
||||
$supervisor_config_data = implode("\n", $supervisorConfig);
|
||||
file_put_contents($supervisorConfigFile, $supervisor_config_data);
|
||||
$supervisorConfigData = implode("\n", $supervisorConfig);
|
||||
file_put_contents($supervisorConfigFile, $supervisorConfigData);
|
||||
|
||||
// Write supporting configurations.
|
||||
$frontend?->write($station);
|
||||
|
@ -185,10 +185,10 @@ final class Configuration
|
|||
|
||||
// Reload Supervisord and process groups
|
||||
if ($reloadSupervisor) {
|
||||
$affected_groups = $this->reloadSupervisor();
|
||||
$was_restarted = in_array($stationGroup, $affected_groups, true);
|
||||
$affectedGroups = $this->reloadSupervisor();
|
||||
$wasRestarted = in_array($stationGroup, $affectedGroups, true);
|
||||
|
||||
if (!$was_restarted && $forceRestart) {
|
||||
if (!$wasRestarted && $forceRestart) {
|
||||
try {
|
||||
if ($attemptReload && ($backendEnum->isEnabled() || $frontendEnum->supportsReload())) {
|
||||
$backend?->reload($station);
|
||||
|
@ -233,12 +233,12 @@ final class Configuration
|
|||
{
|
||||
$this->markAsStarted($station);
|
||||
|
||||
$station_group = 'station_' . $station->getId();
|
||||
$affected_groups = $this->reloadSupervisor();
|
||||
$stationGroup = 'station_' . $station->getId();
|
||||
$affectedGroups = $this->reloadSupervisor();
|
||||
|
||||
if (!in_array($station_group, $affected_groups, true)) {
|
||||
if (!in_array($stationGroup, $affectedGroups, true)) {
|
||||
try {
|
||||
$this->supervisor->stopProcessGroup($station_group, false);
|
||||
$this->supervisor->stopProcessGroup($stationGroup, false);
|
||||
} catch (SupervisorException) {
|
||||
}
|
||||
}
|
||||
|
@ -272,27 +272,27 @@ final class Configuration
|
|||
$station->getFrontendType()->isEnabled()
|
||||
|| $station->getBackendType()->isEnabled()
|
||||
) {
|
||||
$frontend_config = $station->getFrontendConfig();
|
||||
$backend_config = $station->getBackendConfig();
|
||||
$frontendConfig = $station->getFrontendConfig();
|
||||
$backendConfig = $station->getBackendConfig();
|
||||
|
||||
$base_port = $frontend_config->getPort();
|
||||
if ($force || null === $base_port) {
|
||||
$base_port = $this->getFirstAvailableRadioPort($station);
|
||||
$basePort = $frontendConfig->getPort();
|
||||
if ($force || null === $basePort) {
|
||||
$basePort = $this->getFirstAvailableRadioPort($station);
|
||||
|
||||
$frontend_config->setPort($base_port);
|
||||
$station->setFrontendConfig($frontend_config);
|
||||
$frontendConfig->setPort($basePort);
|
||||
$station->setFrontendConfig($frontendConfig);
|
||||
}
|
||||
|
||||
$djPort = $backend_config->getDjPort();
|
||||
$djPort = $backendConfig->getDjPort();
|
||||
if ($force || null === $djPort) {
|
||||
$backend_config->setDjPort($base_port + 5);
|
||||
$station->setBackendConfig($backend_config);
|
||||
$backendConfig->setDjPort($basePort + 5);
|
||||
$station->setBackendConfig($backendConfig);
|
||||
}
|
||||
|
||||
$telnetPort = $backend_config->getTelnetPort();
|
||||
$telnetPort = $backendConfig->getTelnetPort();
|
||||
if ($force || null === $telnetPort) {
|
||||
$backend_config->setTelnetPort($base_port + 4);
|
||||
$station->setBackendConfig($backend_config);
|
||||
$backendConfig->setTelnetPort($basePort + 4);
|
||||
$station->setBackendConfig($backendConfig);
|
||||
}
|
||||
|
||||
$this->em->persist($station);
|
||||
|
@ -305,28 +305,28 @@ final class Configuration
|
|||
*/
|
||||
public function getFirstAvailableRadioPort(Station $station = null): int
|
||||
{
|
||||
$used_ports = $this->getUsedPorts($station);
|
||||
$usedPorts = $this->getUsedPorts($station);
|
||||
|
||||
// Iterate from port 8000 to 9000, in increments of 10
|
||||
$protected_ports = self::PROTECTED_PORTS;
|
||||
$protectedPorts = self::PROTECTED_PORTS;
|
||||
|
||||
$port_min = $this->environment->getAutoAssignPortMin();
|
||||
$port_max = $this->environment->getAutoAssignPortMax();
|
||||
$portMin = $this->environment->getAutoAssignPortMin();
|
||||
$portMax = $this->environment->getAutoAssignPortMax();
|
||||
|
||||
for ($port = $port_min; $port <= $port_max; $port += 10) {
|
||||
if (in_array($port, $protected_ports, true)) {
|
||||
for ($port = $portMin; $port <= $portMax; $port += 10) {
|
||||
if (in_array($port, $protectedPorts, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$range_in_use = false;
|
||||
$rangeInUse = false;
|
||||
for ($i = $port; $i < $port + 10; $i++) {
|
||||
if (isset($used_ports[$i])) {
|
||||
$range_in_use = true;
|
||||
if (isset($usedPorts[$i])) {
|
||||
$rangeInUse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$range_in_use) {
|
||||
if (!$rangeInUse) {
|
||||
return $port;
|
||||
}
|
||||
}
|
||||
|
@ -337,60 +337,60 @@ final class Configuration
|
|||
/**
|
||||
* Get an array of all used ports across the system, except the ones used by the station specified (if specified).
|
||||
*/
|
||||
public function getUsedPorts(Station $except_station = null): array
|
||||
public function getUsedPorts(Station $exceptStation = null): array
|
||||
{
|
||||
static $used_ports;
|
||||
static $usedPorts;
|
||||
|
||||
if (null === $used_ports) {
|
||||
$used_ports = [];
|
||||
if (null === $usedPorts) {
|
||||
$usedPorts = [];
|
||||
|
||||
// Get all station used ports.
|
||||
$station_configs = $this->em->createQuery(
|
||||
$stationConfigs = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT s.id, s.name, s.frontend_type, s.frontend_config, s.backend_type, s.backend_config
|
||||
FROM App\Entity\Station s
|
||||
DQL
|
||||
)->getArrayResult();
|
||||
|
||||
foreach ($station_configs as $row) {
|
||||
$station_reference = ['id' => $row['id'], 'name' => $row['name']];
|
||||
foreach ($stationConfigs as $row) {
|
||||
$stationReference = ['id' => $row['id'], 'name' => $row['name']];
|
||||
|
||||
if ($row['frontend_type'] !== FrontendAdapters::Remote->value) {
|
||||
$frontend_config = (array)$row['frontend_config'];
|
||||
$frontendConfig = (array)$row['frontend_config'];
|
||||
|
||||
if (!empty($frontend_config['port'])) {
|
||||
$port = (int)$frontend_config['port'];
|
||||
$used_ports[$port] = $station_reference;
|
||||
if (!empty($frontendConfig['port'])) {
|
||||
$port = (int)$frontendConfig['port'];
|
||||
$usedPorts[$port] = $stationReference;
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['backend_type'] !== BackendAdapters::None->value) {
|
||||
$backend_config = (array)$row['backend_config'];
|
||||
$backendConfig = (array)$row['backend_config'];
|
||||
|
||||
// For DJ port, consider both the assigned port and port+1 to be reserved and in-use.
|
||||
if (!empty($backend_config['dj_port'])) {
|
||||
$port = (int)$backend_config['dj_port'];
|
||||
$used_ports[$port] = $station_reference;
|
||||
$used_ports[$port + 1] = $station_reference;
|
||||
if (!empty($backendConfig['dj_port'])) {
|
||||
$port = (int)$backendConfig['dj_port'];
|
||||
$usedPorts[$port] = $stationReference;
|
||||
$usedPorts[$port + 1] = $stationReference;
|
||||
}
|
||||
if (!empty($backend_config['telnet_port'])) {
|
||||
$port = (int)$backend_config['telnet_port'];
|
||||
$used_ports[$port] = $station_reference;
|
||||
if (!empty($backendConfig['telnet_port'])) {
|
||||
$port = (int)$backendConfig['telnet_port'];
|
||||
$usedPorts[$port] = $stationReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $except_station && null !== $except_station->getId()) {
|
||||
if (null !== $exceptStation && null !== $exceptStation->getId()) {
|
||||
return array_filter(
|
||||
$used_ports,
|
||||
static function ($station_reference) use ($except_station) {
|
||||
return ($station_reference['id'] !== $except_station->getId());
|
||||
$usedPorts,
|
||||
static function ($stationReference) use ($exceptStation) {
|
||||
return ($stationReference['id'] !== $exceptStation->getId());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return $used_ports;
|
||||
return $usedPorts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,17 +404,17 @@ final class Configuration
|
|||
return;
|
||||
}
|
||||
|
||||
$station_group = 'station_' . $station->getId();
|
||||
$stationGroup = 'station_' . $station->getId();
|
||||
|
||||
// Try forcing the group to stop, but don't hard-fail if it doesn't.
|
||||
try {
|
||||
$this->supervisor->stopProcessGroup($station_group);
|
||||
$this->supervisor->removeProcessGroup($station_group);
|
||||
$this->supervisor->stopProcessGroup($stationGroup);
|
||||
$this->supervisor->removeProcessGroup($stationGroup);
|
||||
} catch (SupervisorException) {
|
||||
}
|
||||
|
||||
$supervisor_config_path = $this->getSupervisorConfigFile($station);
|
||||
@unlink($supervisor_config_path);
|
||||
$supervisorConfigPath = $this->getSupervisorConfigFile($station);
|
||||
@unlink($supervisorConfigPath);
|
||||
|
||||
$this->reloadSupervisor();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
|
||||
public function __construct(
|
||||
protected AdapterFactory $adapterFactory,
|
||||
protected Client $http_client,
|
||||
protected Client $httpClient,
|
||||
protected StationMountRepository $stationMountRepo,
|
||||
SupervisorInterface $supervisor,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
|
@ -49,22 +49,22 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
|
||||
/**
|
||||
* @param Station $station
|
||||
* @param UriInterface|null $base_url
|
||||
* @param UriInterface|null $baseUrl
|
||||
*/
|
||||
public function getStreamUrl(Station $station, UriInterface $base_url = null): UriInterface
|
||||
public function getStreamUrl(Station $station, UriInterface $baseUrl = null): UriInterface
|
||||
{
|
||||
$default_mount = $this->stationMountRepo->getDefaultMount($station);
|
||||
$defaultMount = $this->stationMountRepo->getDefaultMount($station);
|
||||
|
||||
return $this->getUrlForMount($station, $default_mount, $base_url);
|
||||
return $this->getUrlForMount($station, $defaultMount, $baseUrl);
|
||||
}
|
||||
|
||||
public function getUrlForMount(
|
||||
Station $station,
|
||||
?StationMount $mount = null,
|
||||
?UriInterface $base_url = null
|
||||
?UriInterface $baseUrl = null
|
||||
): UriInterface {
|
||||
if ($mount === null) {
|
||||
return $this->getPublicUrl($station, $base_url);
|
||||
return $this->getPublicUrl($station, $baseUrl);
|
||||
}
|
||||
|
||||
$customListenUri = $mount->getCustomListenUrlAsUri();
|
||||
|
@ -72,50 +72,50 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
return $customListenUri;
|
||||
}
|
||||
|
||||
$public_url = $this->getPublicUrl($station, $base_url);
|
||||
return $public_url->withPath($public_url->getPath() . $mount->getName());
|
||||
$publicUrl = $this->getPublicUrl($station, $baseUrl);
|
||||
return $publicUrl->withPath($publicUrl->getPath() . $mount->getName());
|
||||
}
|
||||
|
||||
public function getPublicUrl(Station $station, ?UriInterface $base_url = null): UriInterface
|
||||
public function getPublicUrl(Station $station, ?UriInterface $baseUrl = null): UriInterface
|
||||
{
|
||||
$radio_port = $station->getFrontendConfig()->getPort();
|
||||
$base_url ??= $this->router->getBaseUrl();
|
||||
$radioPort = $station->getFrontendConfig()->getPort();
|
||||
$baseUrl ??= $this->router->getBaseUrl();
|
||||
|
||||
$use_radio_proxy = $this->readSettings()->getUseRadioProxy();
|
||||
$useRadioProxy = $this->readSettings()->getUseRadioProxy();
|
||||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|| 'https' === $base_url->getScheme()
|
||||
$useRadioProxy
|
||||
|| 'https' === $baseUrl->getScheme()
|
||||
|| (!$this->environment->isProduction() && !$this->environment->isDocker())
|
||||
) {
|
||||
// Web proxy support.
|
||||
return $base_url
|
||||
->withPath($base_url->getPath() . CustomUrls::getListenUrl($station));
|
||||
return $baseUrl
|
||||
->withPath($baseUrl->getPath() . CustomUrls::getListenUrl($station));
|
||||
}
|
||||
|
||||
// Remove port number and other decorations.
|
||||
return $base_url
|
||||
->withPort($radio_port)
|
||||
return $baseUrl
|
||||
->withPort($radioPort)
|
||||
->withPath('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Station $station
|
||||
* @param UriInterface|null $base_url
|
||||
* @param UriInterface|null $baseUrl
|
||||
*
|
||||
* @return UriInterface[]
|
||||
*/
|
||||
public function getStreamUrls(Station $station, UriInterface $base_url = null): array
|
||||
public function getStreamUrls(Station $station, UriInterface $baseUrl = null): array
|
||||
{
|
||||
$urls = [];
|
||||
foreach ($station->getMounts() as $mount) {
|
||||
$urls[] = $this->getUrlForMount($station, $mount, $base_url);
|
||||
$urls[] = $this->getUrlForMount($station, $mount, $baseUrl);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
abstract public function getAdminUrl(Station $station, UriInterface $base_url = null): UriInterface;
|
||||
abstract public function getAdminUrl(Station $station, UriInterface $baseUrl = null): UriInterface;
|
||||
|
||||
public function getNowPlaying(Station $station, bool $includeClients = true): Result
|
||||
{
|
||||
|
@ -123,19 +123,19 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $custom_config_raw
|
||||
* @param string $customConfigRaw
|
||||
*
|
||||
* @return mixed[]|false
|
||||
*/
|
||||
protected function processCustomConfig(string $custom_config_raw): array|false
|
||||
protected function processCustomConfig(string $customConfigRaw): array|false
|
||||
{
|
||||
try {
|
||||
if (str_starts_with($custom_config_raw, '{')) {
|
||||
return json_decode($custom_config_raw, true, 512, JSON_THROW_ON_ERROR);
|
||||
if (str_starts_with($customConfigRaw, '{')) {
|
||||
return json_decode($customConfigRaw, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
if (str_starts_with($custom_config_raw, '<')) {
|
||||
$xmlConfig = Reader::fromString('<custom_config>' . $custom_config_raw . '</custom_config>');
|
||||
if (str_starts_with($customConfigRaw, '<')) {
|
||||
$xmlConfig = Reader::fromString('<custom_config>' . $customConfigRaw . '</custom_config>');
|
||||
return (false !== $xmlConfig)
|
||||
? (array)$xmlConfig
|
||||
: false;
|
||||
|
@ -144,7 +144,7 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
$this->logger->error(
|
||||
'Could not parse custom configuration.',
|
||||
[
|
||||
'config' => $custom_config_raw,
|
||||
'config' => $customConfigRaw,
|
||||
'exception' => $e,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -27,16 +27,16 @@ final class Icecast extends AbstractFrontend
|
|||
public function reload(Station $station): void
|
||||
{
|
||||
if ($this->hasCommand($station)) {
|
||||
$program_name = $this->getSupervisorFullName($station);
|
||||
$programName = $this->getSupervisorFullName($station);
|
||||
|
||||
try {
|
||||
$this->supervisor->signalProcess($program_name, 'HUP');
|
||||
$this->supervisor->signalProcess($programName, 'HUP');
|
||||
$this->logger->info(
|
||||
'Adapter "' . self::class . '" reloaded.',
|
||||
['station_id' => $station->getId(), 'station_name' => $station->getName()]
|
||||
);
|
||||
} catch (SupervisorLibException $e) {
|
||||
$this->handleSupervisorException($e, $program_name, $station);
|
||||
$this->handleSupervisorException($e, $programName, $station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,12 +179,11 @@ final class Icecast extends AbstractFrontend
|
|||
$allowedIps = $this->getIpsAsArray($station->getFrontendConfig()->getAllowedIps());
|
||||
$useListenerAuth = !empty($bannedCountries) || !empty($allowedIps);
|
||||
|
||||
foreach ($station->getMounts() as $mount_row) {
|
||||
/** @var StationMount $mount_row */
|
||||
|
||||
/** @var StationMount $mountRow */
|
||||
foreach ($station->getMounts() as $mountRow) {
|
||||
$mount = [
|
||||
'@type' => 'normal',
|
||||
'mount-name' => $mount_row->getName(),
|
||||
'mount-name' => $mountRow->getName(),
|
||||
'charset' => 'UTF8',
|
||||
'stream-name' => $station->getName(),
|
||||
];
|
||||
|
@ -201,12 +200,12 @@ final class Icecast extends AbstractFrontend
|
|||
$mount['genre'] = $station->getGenre();
|
||||
}
|
||||
|
||||
if (!$mount_row->getIsVisibleOnPublicPages()) {
|
||||
if (!$mountRow->getIsVisibleOnPublicPages()) {
|
||||
$mount['hidden'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($mount_row->getIntroPath())) {
|
||||
$introPath = $mount_row->getIntroPath();
|
||||
if (!empty($mountRow->getIntroPath())) {
|
||||
$introPath = $mountRow->getIntroPath();
|
||||
// The intro path is appended to webroot, so the path should be relative to it.
|
||||
$mount['intro'] = Path::makeRelative(
|
||||
$station->getRadioConfigDir() . '/' . $introPath,
|
||||
|
@ -214,36 +213,36 @@ final class Icecast extends AbstractFrontend
|
|||
);
|
||||
}
|
||||
|
||||
if (!empty($mount_row->getFallbackMount())) {
|
||||
$mount['fallback-mount'] = $mount_row->getFallbackMount();
|
||||
if (!empty($mountRow->getFallbackMount())) {
|
||||
$mount['fallback-mount'] = $mountRow->getFallbackMount();
|
||||
$mount['fallback-override'] = 1;
|
||||
} elseif ($mount_row->getEnableAutodj()) {
|
||||
$autoDjFormat = $mount_row->getAutodjFormat() ?? StreamFormats::default();
|
||||
$autoDjBitrate = $mount_row->getAutodjBitrate();
|
||||
} elseif ($mountRow->getEnableAutodj()) {
|
||||
$autoDjFormat = $mountRow->getAutodjFormat() ?? StreamFormats::default();
|
||||
$autoDjBitrate = $mountRow->getAutodjBitrate();
|
||||
|
||||
$mount['fallback-mount'] = '/fallback-[' . $autoDjBitrate . '].' . $autoDjFormat->getExtension();
|
||||
$mount['fallback-override'] = 1;
|
||||
}
|
||||
|
||||
if ($mount_row->getMaxListenerDuration()) {
|
||||
$mount['max-listener-duration'] = $mount_row->getMaxListenerDuration();
|
||||
if ($mountRow->getMaxListenerDuration()) {
|
||||
$mount['max-listener-duration'] = $mountRow->getMaxListenerDuration();
|
||||
}
|
||||
|
||||
$mountFrontendConfig = trim($mount_row->getFrontendConfig() ?? '');
|
||||
$mountFrontendConfig = trim($mountRow->getFrontendConfig() ?? '');
|
||||
if (!empty($mountFrontendConfig)) {
|
||||
$mount_conf = $this->processCustomConfig($mountFrontendConfig);
|
||||
if (false !== $mount_conf) {
|
||||
$mount = Utilities\Arrays::arrayMergeRecursiveDistinct($mount, $mount_conf);
|
||||
$mountConf = $this->processCustomConfig($mountFrontendConfig);
|
||||
if (false !== $mountConf) {
|
||||
$mount = Utilities\Arrays::arrayMergeRecursiveDistinct($mount, $mountConf);
|
||||
}
|
||||
}
|
||||
|
||||
$mountRelayUri = $mount_row->getRelayUrlAsUri();
|
||||
$mountRelayUri = $mountRow->getRelayUrlAsUri();
|
||||
if (null !== $mountRelayUri) {
|
||||
$config['relay'][] = array_filter([
|
||||
'server' => $mountRelayUri->getHost(),
|
||||
'port' => $mountRelayUri->getPort(),
|
||||
'mount' => $mountRelayUri->getPath(),
|
||||
'local-mount' => $mount_row->getName(),
|
||||
'local-mount' => $mountRow->getName(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -311,24 +310,24 @@ final class Icecast extends AbstractFrontend
|
|||
*/
|
||||
public function getBinary(): ?string
|
||||
{
|
||||
$new_path = '/usr/local/bin/icecast';
|
||||
$legacy_path = '/usr/bin/icecast2';
|
||||
$newPath = '/usr/local/bin/icecast';
|
||||
$legacyPath = '/usr/bin/icecast2';
|
||||
|
||||
if ($this->environment->isDocker() || file_exists($new_path)) {
|
||||
return $new_path;
|
||||
if ($this->environment->isDocker() || file_exists($newPath)) {
|
||||
return $newPath;
|
||||
}
|
||||
|
||||
if (file_exists($legacy_path)) {
|
||||
return $legacy_path;
|
||||
if (file_exists($legacyPath)) {
|
||||
return $legacyPath;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAdminUrl(Station $station, UriInterface $base_url = null): UriInterface
|
||||
public function getAdminUrl(Station $station, UriInterface $baseUrl = null): UriInterface
|
||||
{
|
||||
$public_url = $this->getPublicUrl($station, $base_url);
|
||||
return $public_url
|
||||
->withPath($public_url->getPath() . '/admin.html');
|
||||
$publicUrl = $this->getPublicUrl($station, $baseUrl);
|
||||
return $publicUrl
|
||||
->withPath($publicUrl->getPath() . '/admin.html');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ final class Shoutcast extends AbstractFrontend
|
|||
*/
|
||||
public function getBinary(): ?string
|
||||
{
|
||||
$new_path = '/var/azuracast/servers/shoutcast2/sc_serv';
|
||||
return file_exists($new_path)
|
||||
? $new_path
|
||||
$newPath = '/var/azuracast/servers/shoutcast2/sc_serv';
|
||||
return file_exists($newPath)
|
||||
? $newPath
|
||||
: null;
|
||||
}
|
||||
|
||||
|
@ -147,41 +147,42 @@ final class Shoutcast extends AbstractFrontend
|
|||
|
||||
$customConfig = trim($frontendConfig->getCustomConfiguration() ?? '');
|
||||
if (!empty($customConfig)) {
|
||||
$custom_conf = $this->processCustomConfig($customConfig);
|
||||
$customConf = $this->processCustomConfig($customConfig);
|
||||
|
||||
if (false !== $custom_conf) {
|
||||
$config = array_merge($config, $custom_conf);
|
||||
if (false !== $customConf) {
|
||||
$config = array_merge($config, $customConf);
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($station->getMounts() as $mount_row) {
|
||||
/** @var StationMount $mount_row */
|
||||
|
||||
/** @var StationMount $mountRow */
|
||||
foreach ($station->getMounts() as $mountRow) {
|
||||
$i++;
|
||||
$config['streamid_' . $i] = $i;
|
||||
$config['streampath_' . $i] = $mount_row->getName();
|
||||
$config['streampath_' . $i] = $mountRow->getName();
|
||||
|
||||
if (!empty($mount_row->getIntroPath())) {
|
||||
$introPath = $mount_row->getIntroPath();
|
||||
if (!empty($mountRow->getIntroPath())) {
|
||||
$introPath = $mountRow->getIntroPath();
|
||||
$config['streamintrofile_' . $i] = $station->getRadioConfigDir() . '/' . $introPath;
|
||||
}
|
||||
|
||||
if ($mount_row->getRelayUrl()) {
|
||||
$config['streamrelayurl_' . $i] = $mount_row->getRelayUrl();
|
||||
if ($mountRow->getRelayUrl()) {
|
||||
$config['streamrelayurl_' . $i] = $mountRow->getRelayUrl();
|
||||
}
|
||||
|
||||
if ($mount_row->getAuthhash()) {
|
||||
$config['streamauthhash_' . $i] = $mount_row->getAuthhash();
|
||||
if ($mountRow->getAuthhash()) {
|
||||
$config['streamauthhash_' . $i] = $mountRow->getAuthhash();
|
||||
}
|
||||
|
||||
if ($mount_row->getMaxListenerDuration()) {
|
||||
$config['streamlistenertime_' . $i] = $mount_row->getMaxListenerDuration();
|
||||
if ($mountRow->getMaxListenerDuration()) {
|
||||
$config['streamlistenertime_' . $i] = $mountRow->getMaxListenerDuration();
|
||||
}
|
||||
}
|
||||
|
||||
$configFileOutput = '';
|
||||
foreach ($config as $config_key => $config_value) {
|
||||
$configFileOutput .= $config_key . '=' . str_replace("\n", '', (string)$config_value) . "\n";
|
||||
foreach ($config as $configKey => $configValue) {
|
||||
$configFileOutput .= $configKey . '=' . str_replace("\n", '', (string)$configValue) . "\n";
|
||||
}
|
||||
|
||||
return $configFileOutput;
|
||||
|
@ -195,11 +196,11 @@ final class Shoutcast extends AbstractFrontend
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getAdminUrl(Station $station, UriInterface $base_url = null): UriInterface
|
||||
public function getAdminUrl(Station $station, UriInterface $baseUrl = null): UriInterface
|
||||
{
|
||||
$public_url = $this->getPublicUrl($station, $base_url);
|
||||
return $public_url
|
||||
->withPath($public_url->getPath() . '/admin.cgi');
|
||||
$publicUrl = $this->getPublicUrl($station, $baseUrl);
|
||||
return $publicUrl
|
||||
->withPath($publicUrl->getPath() . '/admin.cgi');
|
||||
}
|
||||
|
||||
protected function writeIpBansFile(
|
||||
|
|
|
@ -13,10 +13,10 @@ final class PlaylistParser
|
|||
{
|
||||
// Process as full PLS if the header is present.
|
||||
if (str_starts_with($playlistRaw, '[playlist]')) {
|
||||
$parsed_playlist = (array)parse_ini_string($playlistRaw, true, INI_SCANNER_RAW);
|
||||
$parsedPlaylist = (array)parse_ini_string($playlistRaw, true, INI_SCANNER_RAW);
|
||||
|
||||
return array_filter(
|
||||
$parsed_playlist['playlist'],
|
||||
$parsedPlaylist['playlist'],
|
||||
static function ($key) {
|
||||
return str_starts_with(strtolower($key), 'file');
|
||||
},
|
||||
|
|
|
@ -25,20 +25,20 @@ final class Quota
|
|||
|
||||
public static function getReadableSize(Math\BigInteger $bytes, int $decimals = 1): string
|
||||
{
|
||||
$bytes_str = (string)$bytes;
|
||||
$bytesStr = (string)$bytes;
|
||||
|
||||
$size = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
$factor = (int)floor((strlen($bytes_str) - 1) / 3);
|
||||
$factor = (int)floor((strlen($bytesStr) - 1) / 3);
|
||||
|
||||
if (isset($size[$factor])) {
|
||||
$byte_divisor = Math\BigInteger::of(1000)->power($factor);
|
||||
$size_string = $bytes->toBigDecimal()
|
||||
->dividedBy($byte_divisor, $decimals, Math\RoundingMode::HALF_DOWN);
|
||||
$byteDivisor = Math\BigInteger::of(1000)->power($factor);
|
||||
$sizeString = $bytes->toBigDecimal()
|
||||
->dividedBy($byteDivisor, $decimals, Math\RoundingMode::HALF_DOWN);
|
||||
|
||||
return $size_string . ' ' . $size[$factor];
|
||||
return $sizeString . ' ' . $size[$factor];
|
||||
}
|
||||
|
||||
return $bytes_str;
|
||||
return $bytesStr;
|
||||
}
|
||||
|
||||
public static function convertFromReadableSize(Math\BigInteger|string|null $size): ?Math\BigInteger
|
||||
|
@ -62,14 +62,14 @@ final class Quota
|
|||
// of magnitude to multiply a kilobyte by.
|
||||
|
||||
/** @noinspection StringFragmentMisplacedInspection */
|
||||
$byte_power = stripos(
|
||||
$bytePower = stripos(
|
||||
haystack: 'bkmgtpezy',
|
||||
needle: $unit[0]
|
||||
) ?: 0;
|
||||
$byte_multiplier = Math\BigInteger::of(1000)->power($byte_power);
|
||||
$byteMultiplier = Math\BigInteger::of(1000)->power($bytePower);
|
||||
|
||||
return Math\BigDecimal::of($size)
|
||||
->multipliedBy($byte_multiplier)
|
||||
->multipliedBy($byteMultiplier)
|
||||
->toScale(0, Math\RoundingMode::FLOOR)
|
||||
->toBigInteger();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract class AbstractRemote
|
|||
use EntityManagerAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected Client $http_client,
|
||||
protected Client $httpClient,
|
||||
protected AdapterFactory $adapterFactory
|
||||
) {
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ abstract class AbstractRemote
|
|||
*/
|
||||
public function getPublicUrl(StationRemote $remote): string
|
||||
{
|
||||
$custom_listen_url = $remote->getCustomListenUrl();
|
||||
$customListenUrl = $remote->getCustomListenUrl();
|
||||
|
||||
return (!empty($custom_listen_url))
|
||||
? $custom_listen_url
|
||||
return (!empty($customListenUrl))
|
||||
? $customListenUrl
|
||||
: $this->getRemoteUrl($remote, $remote->getMount());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ final class AzuraRelay extends AbstractRemote
|
|||
|
||||
public function __construct(
|
||||
private readonly AzuraRelayCache $azuraRelayCache,
|
||||
Client $http_client,
|
||||
Client $httpClient,
|
||||
AdapterFactory $adapterFactory,
|
||||
) {
|
||||
parent::__construct($http_client, $adapterFactory);
|
||||
parent::__construct($httpClient, $adapterFactory);
|
||||
}
|
||||
|
||||
public function getNowPlayingAsync(StationRemote $remote, bool $includeClients = false): PromiseInterface
|
||||
|
@ -86,25 +86,25 @@ final class AzuraRelay extends AbstractRemote
|
|||
throw new InvalidArgumentException('AzuraRelay remote must have a corresponding relay.');
|
||||
}
|
||||
|
||||
$base_url = new Uri(rtrim($relay->getBaseUrl(), '/'));
|
||||
$baseUrl = new Uri(rtrim($relay->getBaseUrl(), '/'));
|
||||
|
||||
$radio_port = $station->getFrontendConfig()->getPort();
|
||||
$radioPort = $station->getFrontendConfig()->getPort();
|
||||
|
||||
$use_radio_proxy = $this->readSettings()->getUseRadioProxy();
|
||||
$useRadioProxy = $this->readSettings()->getUseRadioProxy();
|
||||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|| 'https' === $base_url->getScheme()
|
||||
$useRadioProxy
|
||||
|| 'https' === $baseUrl->getScheme()
|
||||
|| (!$this->environment->isProduction() && !$this->environment->isDocker())
|
||||
) {
|
||||
// Web proxy support.
|
||||
return (string)$base_url
|
||||
->withPath($base_url->getPath() . '/radio/' . $radio_port . $remote->getMount());
|
||||
return (string)$baseUrl
|
||||
->withPath($baseUrl->getPath() . '/radio/' . $radioPort . $remote->getMount());
|
||||
}
|
||||
|
||||
// Remove port number and other decorations.
|
||||
return (string)$base_url
|
||||
->withPort($radio_port)
|
||||
return (string)$baseUrl
|
||||
->withPort($radioPort)
|
||||
->withPath($remote->getMount() ?? '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,11 +55,11 @@ final class SplitToken
|
|||
|
||||
public static function generate(): self
|
||||
{
|
||||
$random_str = hash('sha256', random_bytes(32));
|
||||
$randomStr = hash('sha256', random_bytes(32));
|
||||
|
||||
$token = new self();
|
||||
$token->identifier = substr($random_str, 0, 16);
|
||||
$token->verifier = substr($random_str, 16, 32);
|
||||
$token->identifier = substr($randomStr, 0, 16);
|
||||
$token->verifier = substr($randomStr, 16, 32);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue