Implement SettingsAwareTrait.
This commit is contained in:
parent
7d1b987d32
commit
a7dd57429e
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -18,9 +18,10 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class ClearCacheCommand extends CommandAbstract
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly AdapterInterface $cache,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AdapterInterface $cache
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ final class ClearCacheCommand extends CommandAbstract
|
|||
$this->cache->clear();
|
||||
|
||||
// Clear cached system settings.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->updateUpdateLastRun();
|
||||
$settings->setUpdateResults(null);
|
||||
|
||||
|
@ -41,7 +42,7 @@ final class ClearCacheCommand extends CommandAbstract
|
|||
$settings->setExternalIp(null);
|
||||
}
|
||||
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
$io->success('Local cache flushed.');
|
||||
return 0;
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Settings;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Utilities;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -18,11 +18,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class ListCommand extends CommandAbstract
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsTableRepo,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
@ -35,8 +31,8 @@ final class ListCommand extends CommandAbstract
|
|||
];
|
||||
$rows = [];
|
||||
|
||||
$settings = $this->settingsTableRepo->readSettings();
|
||||
foreach ($this->settingsTableRepo->toArray($settings) as $setting_key => $setting_value) {
|
||||
$settings = $this->readSettings();
|
||||
foreach ($this->settingsRepo->toArray($settings) as $setting_key => $setting_value) {
|
||||
$value = print_r($setting_value, true);
|
||||
$value = Utilities\Strings::truncateText($value, 600);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Settings;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -18,11 +18,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class SetCommand extends CommandAbstract
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsTableRepo,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
|
@ -40,7 +36,7 @@ final class SetCommand extends CommandAbstract
|
|||
$io->title('AzuraCast Settings');
|
||||
|
||||
if (strtolower($settingValue) === 'null') {
|
||||
$this->settingsTableRepo->writeSettings([$settingKey => null]);
|
||||
$this->writeSettings([$settingKey => null]);
|
||||
|
||||
$io->success(sprintf('Setting "%s" removed.', $settingKey));
|
||||
return 0;
|
||||
|
@ -50,7 +46,7 @@ final class SetCommand extends CommandAbstract
|
|||
$settingValue = json_decode($settingValue, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
$this->settingsTableRepo->writeSettings([$settingKey => $settingValue]);
|
||||
$this->writeSettings([$settingKey => $settingValue]);
|
||||
|
||||
$io->success(sprintf('Setting "%s" updated.', $settingKey));
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Repository\StorageLocationRepository;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
@ -21,9 +21,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
final class SetupCommand extends CommandAbstract
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AzuraCastCentral $acCentral,
|
||||
private readonly StorageLocationRepository $storageLocationRepo
|
||||
) {
|
||||
|
@ -115,9 +115,9 @@ final class SetupCommand extends CommandAbstract
|
|||
}
|
||||
|
||||
// Update system setting logging when updates were last run.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->updateUpdateLastRun();
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
if ($update) {
|
||||
$io->success(
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace App\Console\Command\Sync;
|
|||
|
||||
use App\Cache\NowPlayingCache;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Lock\LockFactory;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -23,11 +23,11 @@ use function random_int;
|
|||
final class NowPlayingCommand extends AbstractSyncCommand
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public final const MAX_CONCURRENT_PROCESSES = 5;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly NowPlayingCache $nowPlayingCache,
|
||||
LockFactory $lockFactory,
|
||||
) {
|
||||
|
@ -49,7 +49,7 @@ final class NowPlayingCommand extends AbstractSyncCommand
|
|||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if ($settings->getSyncDisabled()) {
|
||||
$this->logger->error('Automated synchronization is temporarily disabled.');
|
||||
return 1;
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command\Sync;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Event\GetSyncTasks;
|
||||
use App\Lock\LockFactory;
|
||||
use App\Sync\Task\AbstractTask;
|
||||
|
@ -25,9 +25,10 @@ use function usleep;
|
|||
)]
|
||||
final class RunnerCommand extends AbstractSyncCommand
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly EventDispatcherInterface $dispatcher,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
LockFactory $lockFactory
|
||||
) {
|
||||
parent::__construct($lockFactory);
|
||||
|
@ -37,7 +38,7 @@ final class RunnerCommand extends AbstractSyncCommand
|
|||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if ($settings->getSyncDisabled()) {
|
||||
$io->error('Automated synchronization is temporarily disabled.');
|
||||
return 1;
|
||||
|
@ -60,7 +61,7 @@ final class RunnerCommand extends AbstractSyncCommand
|
|||
$this->manageStartedEvents();
|
||||
|
||||
$settings->updateSyncLastRun();
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Container;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Settings;
|
||||
use DI\Attribute\Inject;
|
||||
|
||||
trait SettingsAwareTrait
|
||||
{
|
||||
protected SettingsRepository $settingsRepo;
|
||||
|
||||
#[Inject]
|
||||
public function setSettingsRepo(SettingsRepository $settingsRepo): void
|
||||
{
|
||||
$this->settingsRepo = $settingsRepo;
|
||||
}
|
||||
|
||||
public function readSettings(): Settings
|
||||
{
|
||||
return $this->settingsRepo->readSettings();
|
||||
}
|
||||
|
||||
public function writeSettings(Settings|array $settings): void
|
||||
{
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Version;
|
||||
|
@ -12,9 +12,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||
final class UpdatesAction
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly Version $version
|
||||
) {
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ final class UpdatesAction
|
|||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$router = $request->getRouter();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin\GeoLite;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\IpGeolocator\GeoLite;
|
||||
|
@ -12,17 +12,14 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class GetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
$version = GeoLite::getVersion();
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
return $response->withJson(
|
||||
[
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin\GeoLite;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\IpGeolocator\GeoLite;
|
||||
|
@ -13,8 +13,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class PostAction
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly UpdateGeoLiteTask $geoLiteTask
|
||||
) {
|
||||
}
|
||||
|
@ -25,9 +26,9 @@ final class PostAction
|
|||
): ResponseInterface {
|
||||
$newKey = trim($request->getParsedBodyParam('geolite_license_key', ''));
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->setGeoliteLicenseKey($newKey);
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
if (!empty($newKey)) {
|
||||
$this->geoLiteTask->updateDatabase($newKey);
|
||||
|
|
|
@ -6,10 +6,10 @@ namespace App\Controller\Api\Admin;
|
|||
|
||||
use App\Cache\AzuraRelayCache;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Admin\Relay as ApiRelay;
|
||||
use App\Entity\Api\Status;
|
||||
use App\Entity\Relay;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationMount;
|
||||
use App\Entity\StationRemote;
|
||||
|
@ -44,10 +44,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||
final class RelaysController
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Adapters $adapters,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AzuraRelayCache $azuraRelayCache
|
||||
) {
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ final class RelaysController
|
|||
$base_url = $body['base_url'];
|
||||
} else {
|
||||
/** @noinspection HttpUrlsUsage */
|
||||
$base_url = 'http://' . $this->settingsRepo->readSettings()->getIp($request);
|
||||
$base_url = 'http://' . $this->readSettings()->getIp($request);
|
||||
}
|
||||
|
||||
$relay = $relay_repo->findOneBy(['base_url' => $base_url]);
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Controller\Api\AbstractApiCrudController;
|
||||
use App\Entity\Api\Status;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Settings;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
|
@ -53,10 +53,11 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|||
]
|
||||
final class SettingsController extends AbstractApiCrudController
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
protected string $entityClass = Settings::class;
|
||||
|
||||
public function __construct(
|
||||
protected SettingsRepository $settingsRepo,
|
||||
Serializer $serializer,
|
||||
ValidatorInterface $validator
|
||||
) {
|
||||
|
@ -73,7 +74,7 @@ final class SettingsController extends AbstractApiCrudController
|
|||
$context[AbstractNormalizer::GROUPS] = [$group];
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
return $response->withJson($this->toArray($settings, $context));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin\Updates;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\AzuraCastCentral;
|
||||
|
@ -14,8 +14,9 @@ use RuntimeException;
|
|||
|
||||
final class GetUpdatesAction
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AzuraCastCentral $azuracastCentral
|
||||
) {
|
||||
}
|
||||
|
@ -24,7 +25,7 @@ final class GetUpdatesAction
|
|||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
try {
|
||||
$updates = $this->azuracastCentral->checkForUpdates();
|
||||
|
@ -32,7 +33,7 @@ final class GetUpdatesAction
|
|||
if (!empty($updates)) {
|
||||
$settings->setUpdateResults($updates);
|
||||
$settings->updateUpdateLastRun();
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
return $response->withJson($updates);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Frontend\Dashboard;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Error;
|
||||
use App\Entity\Enums\AnalyticsIntervals;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Enums\StationPermissions;
|
||||
|
@ -20,10 +20,10 @@ use Psr\SimpleCache\CacheInterface;
|
|||
final class ChartsAction
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ final class ChartsAction
|
|||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
if (!$this->settingsRepo->readSettings()->isAnalyticsEnabled()) {
|
||||
if (!$this->readSettings()->isAnalyticsEnabled()) {
|
||||
return $response->withStatus(403, 'Forbidden')
|
||||
->withJson(new Error(403, 'Analytics are disabled for this installation.'));
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Frontend\Dashboard;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Dashboard;
|
||||
use App\Entity\ApiGenerator\NowPlayingApiGenerator;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Enums\StationPermissions;
|
||||
use App\Http\Response;
|
||||
|
@ -18,9 +18,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||
final class StationsAction
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly NowPlayingApiGenerator $npApiGenerator
|
||||
) {
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ final class StationsAction
|
|||
}
|
||||
);
|
||||
|
||||
$listenersEnabled = $this->settingsRepo->readSettings()->isAnalyticsEnabled();
|
||||
$listenersEnabled = $this->readSettings()->isAnalyticsEnabled();
|
||||
|
||||
$viewStations = [];
|
||||
foreach ($stations as $station) {
|
||||
|
|
|
@ -5,28 +5,24 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Stations\Reports\Overview;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Controller\Api\Traits\AcceptsDateRange;
|
||||
use App\Entity\Enums\AnalyticsLevel;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
|
||||
abstract class AbstractReportAction
|
||||
{
|
||||
use AcceptsDateRange;
|
||||
use EntityManagerAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
protected function isAllAnalyticsEnabled(): bool
|
||||
{
|
||||
return AnalyticsLevel::All === $this->settingsRepo->readSettings()->getAnalytics();
|
||||
return AnalyticsLevel::All === $this->readSettings()->getAnalytics();
|
||||
}
|
||||
|
||||
protected function isAnalyticsEnabled(): bool
|
||||
{
|
||||
return $this->settingsRepo->readSettings()->isAnalyticsEnabled();
|
||||
return $this->readSettings()->isAnalyticsEnabled();
|
||||
}
|
||||
|
||||
protected function buildChart(
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace App\Controller\Api\Stations\Reports\Overview;
|
|||
|
||||
use App\Entity\Api\Status;
|
||||
use App\Entity\ApiGenerator\SongApiGenerator;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Song;
|
||||
use App\Entity\SongHistory;
|
||||
use App\Http\Response;
|
||||
|
@ -18,9 +17,7 @@ final class BestAndWorstAction extends AbstractReportAction
|
|||
{
|
||||
public function __construct(
|
||||
private readonly SongApiGenerator $songApiGenerator,
|
||||
SettingsRepository $settingsRepo
|
||||
) {
|
||||
parent::__construct($settingsRepo);
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Stations\Reports\Overview;
|
||||
|
||||
use App\Entity\Api\Status;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\StationHlsStreamRepository;
|
||||
use App\Entity\Repository\StationMountRepository;
|
||||
use App\Entity\Repository\StationRemoteRepository;
|
||||
|
@ -18,10 +17,8 @@ final class ByStream extends AbstractReportAction
|
|||
public function __construct(
|
||||
private readonly StationMountRepository $mountRepo,
|
||||
private readonly StationRemoteRepository $remoteRepo,
|
||||
private readonly StationHlsStreamRepository $hlsStreamRepo,
|
||||
SettingsRepository $settingsRepo,
|
||||
private readonly StationHlsStreamRepository $hlsStreamRepo
|
||||
) {
|
||||
parent::__construct($settingsRepo);
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace App\Controller\Api\Stations\Reports\Overview;
|
|||
use App\Entity\Api\Status;
|
||||
use App\Entity\Enums\AnalyticsIntervals;
|
||||
use App\Entity\Repository\AnalyticsRepository;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
@ -17,10 +16,8 @@ use stdClass;
|
|||
final class ChartsAction extends AbstractReportAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AnalyticsRepository $analyticsRepo,
|
||||
SettingsRepository $settingsRepo,
|
||||
private readonly AnalyticsRepository $analyticsRepo
|
||||
) {
|
||||
parent::__construct($settingsRepo);
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Stations\Requests;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Error;
|
||||
use App\Entity\Api\Status;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\StationRequestRepository;
|
||||
use App\Entity\User;
|
||||
use App\Exception\InvalidRequestAttribute;
|
||||
|
@ -43,9 +43,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||
]
|
||||
final class SubmitAction
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly StationRequestRepository $requestRepo,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ final class SubmitAction
|
|||
$isAuthenticated = ($user instanceof User);
|
||||
|
||||
try {
|
||||
$ip = $this->settingsRepo->readSettings()->getIp($request);
|
||||
$ip = $this->readSettings()->getIp($request);
|
||||
|
||||
$this->requestRepo->submit(
|
||||
$station,
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Frontend\Account;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\User;
|
||||
use App\Exception\RateLimitExceededException;
|
||||
use App\Http\Response;
|
||||
|
@ -17,10 +17,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||
final class LoginAction
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly RateLimit $rateLimit,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
private readonly RateLimit $rateLimit
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ final class LoginAction
|
|||
$acl = $request->getAcl();
|
||||
|
||||
// Check installation completion progress.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
if (!$settings->isSetupComplete()) {
|
||||
$num_users = (int)$this->em->createQuery(
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
|
@ -12,16 +12,13 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class DashboardAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
// Detect current analytics level.
|
||||
$showCharts = $settings->isAnalyticsEnabled();
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Frontend;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\User;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
|
@ -12,17 +12,14 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class IndexAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
// Redirect to complete setup, if it hasn't been completed yet.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if (!$settings->isSetupComplete()) {
|
||||
return $response->withRedirect($request->getRouter()->named('setup:index'));
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace App\Controller\Frontend;
|
|||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Repository\RolePermissionRepository;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Settings;
|
||||
use App\Entity\User;
|
||||
use App\Exception\NotLoggedInException;
|
||||
|
@ -25,9 +25,9 @@ final class SetupController
|
|||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly RolePermissionRepository $permissionRepo,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly StationFormComponent $stationFormComponent,
|
||||
|
@ -203,7 +203,7 @@ final class SetupController
|
|||
*/
|
||||
private function getSetupStep(ServerRequest $request): string
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if ($settings->isSetupComplete()) {
|
||||
return 'complete';
|
||||
}
|
||||
|
|
|
@ -4,17 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class MountsAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
@ -24,7 +21,7 @@ final class MountsAction
|
|||
$router = $request->getRouter();
|
||||
$station = $request->getStation();
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
return $request->getView()->renderVuePage(
|
||||
response: $response,
|
||||
|
|
|
@ -4,17 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class PlaylistsAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
@ -23,7 +20,7 @@ final class PlaylistsAction
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$router = $request->getRouter();
|
||||
|
||||
return $request->getView()->renderVuePage(
|
||||
|
|
|
@ -4,18 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations\Reports;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Enums\AnalyticsLevel;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class OverviewAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
@ -23,7 +20,7 @@ final class OverviewAction
|
|||
string $station_id
|
||||
): ResponseInterface {
|
||||
// Get current analytics level.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
if (!$settings->isAnalyticsEnabled()) {
|
||||
// The entirety of the dashboard can't be shown, so redirect user to the profile page.
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\AzuraCastCentral;
|
||||
|
@ -12,9 +12,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class StreamersAction
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly AzuraCastCentral $acCentral,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -25,7 +26,7 @@ final class StreamersAction
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$backendConfig = $station->getBackendConfig();
|
||||
|
||||
$router = $request->getRouter();
|
||||
|
|
|
@ -4,17 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class WebhooksAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
@ -23,7 +20,7 @@ final class WebhooksAction
|
|||
): ResponseInterface {
|
||||
$router = $request->getRouter();
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
return $request->getView()->renderVuePage(
|
||||
response: $response,
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationHlsStream;
|
||||
|
@ -24,13 +24,7 @@ use Psr\Http\Message\UriInterface;
|
|||
final class StationRepository extends Repository
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
ReloadableEntityManagerInterface $em,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
) {
|
||||
parent::__construct($em);
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
/**
|
||||
* @param string $identifier A numeric or string identifier for a station.
|
||||
|
@ -205,7 +199,7 @@ final class StationRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
$customUrl = $this->settingsRepo->readSettings()->getDefaultAlbumArtUrlAsUri();
|
||||
$customUrl = $this->readSettings()->getDefaultAlbumArtUrlAsUri();
|
||||
return $customUrl ?? AssetTypes::AlbumArt->createObject($this->environment)->getUri();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Traits\RequestAwareTrait;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Psr7\UriResolver;
|
||||
|
@ -18,13 +18,13 @@ use Slim\Routing\RouteContext;
|
|||
final class Router implements RouterInterface
|
||||
{
|
||||
use RequestAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private ?UriInterface $baseUrl = null;
|
||||
|
||||
private ?RouteInterface $currentRoute = null;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly RouteParserInterface $routeParser,
|
||||
) {
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ final class Router implements RouterInterface
|
|||
|
||||
public function buildBaseUrl(?bool $useRequest = null): UriInterface
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$useRequest ??= $settings->getPreferBrowserUrl();
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ declare(strict_types=1);
|
|||
namespace App\Media;
|
||||
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Interfaces\SongInterface;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Song;
|
||||
use App\Event\Media\GetAlbumArt;
|
||||
use App\Version;
|
||||
|
@ -21,12 +21,12 @@ use Throwable;
|
|||
final class RemoteAlbumArt
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public const CACHE_LIFETIME = 86400 * 14; // Two Weeks
|
||||
|
||||
public function __construct(
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly Client $httpClient
|
||||
) {
|
||||
|
@ -34,12 +34,12 @@ final class RemoteAlbumArt
|
|||
|
||||
public function enableForApis(): bool
|
||||
{
|
||||
return $this->settingsRepo->readSettings()->getUseExternalAlbumArtInApis();
|
||||
return $this->readSettings()->getUseExternalAlbumArtInApis();
|
||||
}
|
||||
|
||||
public function enableForMedia(): bool
|
||||
{
|
||||
return $this->settingsRepo->readSettings()->getUseExternalAlbumArtWhenProcessingMedia();
|
||||
return $this->readSettings()->getUseExternalAlbumArtWhenProcessingMedia();
|
||||
}
|
||||
|
||||
public function getArtwork(SongInterface $media): ?string
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -17,10 +17,11 @@ use Slim\App;
|
|||
*/
|
||||
final class EnforceSecurity implements MiddlewareInterface
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private ResponseFactoryInterface $responseFactory;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
App $app
|
||||
) {
|
||||
$this->responseFactory = $app->getResponseFactory();
|
||||
|
@ -32,7 +33,7 @@ final class EnforceSecurity implements MiddlewareInterface
|
|||
*/
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$always_use_ssl = $this->settingsRepo->readSettings()->getAlwaysUseSsl();
|
||||
$always_use_ssl = $this->readSettings()->getAlwaysUseSsl();
|
||||
|
||||
$internal_api_url = mb_stripos($request->getUri()->getPath(), '/api/internal') === 0;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Session\Csrf;
|
||||
|
@ -25,11 +25,12 @@ use Symfony\Component\Cache\Adapter\ProxyAdapter;
|
|||
*/
|
||||
final class InjectSession implements MiddlewareInterface
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private CacheItemPoolInterface $cachePool;
|
||||
|
||||
public function __construct(
|
||||
CacheItemPoolInterface $cachePool,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
if ($environment->isCli()) {
|
||||
|
@ -41,7 +42,7 @@ final class InjectSession implements MiddlewareInterface
|
|||
|
||||
public function getSessionPersistence(ServerRequestInterface $request): SessionPersistenceInterface
|
||||
{
|
||||
$alwaysUseSsl = $this->settingsRepo->readSettings()->getAlwaysUseSsl();
|
||||
$alwaysUseSsl = $this->readSettings()->getAlwaysUseSsl();
|
||||
$isHttpsUrl = ('https' === $request->getUri()->getScheme());
|
||||
|
||||
return new CacheSessionPersistence(
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware\Module;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Event;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -18,15 +18,16 @@ use Slim\Routing\RouteContext;
|
|||
*/
|
||||
final class Admin
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly EventDispatcherInterface $dispatcher,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$event = new Event\BuildAdminMenu($request, $settings);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Middleware\Module;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\User;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
|
@ -23,11 +23,7 @@ use Symfony\Component\VarDumper\VarDumper;
|
|||
final class Api
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
|
@ -47,7 +43,7 @@ final class Api
|
|||
$apiUser = $request->getAttribute(ServerRequest::ATTR_USER);
|
||||
|
||||
// Set default cache control for API pages.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$preferBrowserUrl = $settings->getPreferBrowserUrl();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware\Module;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Event;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -18,9 +18,10 @@ use Slim\Routing\RouteContext;
|
|||
*/
|
||||
final class Stations
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly EventDispatcherInterface $dispatcher,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ final class Stations
|
|||
]
|
||||
);
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$event = new Event\BuildStationMenu($station, $request, $settings);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
|
|
@ -4,18 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Notification;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Session\FlashLevels;
|
||||
|
||||
final class BaseUrlCheck
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(GetNotifications $event): void
|
||||
{
|
||||
|
@ -28,7 +25,7 @@ final class BaseUrlCheck
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
// Base URL mismatch doesn't happen if this setting is enabled.
|
||||
if ($settings->getPreferBrowserUrl()) {
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Notification;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Session\FlashLevels;
|
||||
|
@ -15,11 +15,7 @@ use Carbon\CarbonImmutable;
|
|||
final class RecentBackupCheck
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(GetNotifications $event): void
|
||||
{
|
||||
|
@ -37,7 +33,7 @@ final class RecentBackupCheck
|
|||
$threshold = CarbonImmutable::now()->subWeeks(2)->getTimestamp();
|
||||
|
||||
// Don't show backup warning for freshly created installations.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$setupComplete = $settings->getSetupCompleteTime();
|
||||
if ($setupComplete >= $threshold) {
|
||||
|
|
|
@ -4,18 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Notification;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Session\FlashLevels;
|
||||
|
||||
final class SyncTaskCheck
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __invoke(GetNotifications $event): void
|
||||
{
|
||||
|
@ -26,7 +23,7 @@ final class SyncTaskCheck
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$setupComplete = $settings->getSetupCompleteTime();
|
||||
if ($setupComplete > (time() - 60 * 60 * 2)) {
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\Notification;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Enums\ReleaseChannel;
|
||||
use App\Event\GetNotifications;
|
||||
|
@ -14,9 +14,10 @@ use App\Version;
|
|||
|
||||
final class UpdateCheck
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Version $version,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -28,7 +29,7 @@ final class UpdateCheck
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if (!$settings->getCheckForUpdates()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ declare(strict_types=1);
|
|||
namespace App\Radio\Backend\Liquidsoap;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Enums\PlaylistOrders;
|
||||
use App\Entity\Enums\PlaylistRemoteTypes;
|
||||
use App\Entity\Enums\PlaylistSources;
|
||||
use App\Entity\Enums\PlaylistTypes;
|
||||
use App\Entity\Enums\StationBackendPerformanceModes;
|
||||
use App\Entity\Interfaces\StationMountInterface;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationBackendConfiguration;
|
||||
use App\Entity\StationPlaylist;
|
||||
|
@ -34,9 +34,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
final class ConfigWriter implements EventSubscriberInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly Liquidsoap $liquidsoap,
|
||||
private readonly FallbackFile $fallbackFile
|
||||
) {
|
||||
|
@ -74,7 +74,7 @@ final class ConfigWriter implements EventSubscriberInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
if (!$settings->getEnableAdvancedFeatures()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Repository\StationMountRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationMount;
|
||||
|
@ -26,10 +26,11 @@ use Supervisor\SupervisorInterface;
|
|||
|
||||
abstract class AbstractFrontend extends AbstractLocalAdapter
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected AdapterFactory $adapterFactory,
|
||||
protected Client $http_client,
|
||||
protected SettingsRepository $settingsRepo,
|
||||
protected StationMountRepository $stationMountRepo,
|
||||
SupervisorInterface $supervisor,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
|
@ -80,7 +81,7 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
$radio_port = $station->getFrontendConfig()->getPort();
|
||||
$base_url ??= $this->router->getBaseUrl();
|
||||
|
||||
$use_radio_proxy = $this->settingsRepo->readSettings()->getUseRadioProxy();
|
||||
$use_radio_proxy = $this->readSettings()->getUseRadioProxy();
|
||||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace App\Radio\Remote;
|
|||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\StationRemote;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
|
@ -20,7 +19,6 @@ abstract class AbstractRemote
|
|||
use EntityManagerAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected SettingsRepository $settingsRepo,
|
||||
protected Client $http_client,
|
||||
protected AdapterFactory $adapterFactory
|
||||
) {
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace App\Radio\Remote;
|
|||
|
||||
use App\Cache\AzuraRelayCache;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Relay;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\StationRemote;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Promise\Create;
|
||||
|
@ -21,14 +21,14 @@ use NowPlaying\Result\Result;
|
|||
final class AzuraRelay extends AbstractRemote
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly AzuraRelayCache $azuraRelayCache,
|
||||
SettingsRepository $settingsRepo,
|
||||
Client $http_client,
|
||||
AdapterFactory $adapterFactory,
|
||||
) {
|
||||
parent::__construct($settingsRepo, $http_client, $adapterFactory);
|
||||
parent::__construct($http_client, $adapterFactory);
|
||||
}
|
||||
|
||||
public function getNowPlayingAsync(StationRemote $remote, bool $includeClients = false): PromiseInterface
|
||||
|
@ -90,7 +90,7 @@ final class AzuraRelay extends AbstractRemote
|
|||
|
||||
$radio_port = $station->getFrontendConfig()->getPort();
|
||||
|
||||
$use_radio_proxy = $this->settingsRepo->readSettings()->getUseRadioProxy();
|
||||
$use_radio_proxy = $this->readSettings()->getUseRadioProxy();
|
||||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace App\Service;
|
|||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Repository\StationRepository;
|
||||
use App\Environment;
|
||||
use App\Message\AbstractMessage;
|
||||
|
@ -24,13 +24,13 @@ final class Acme
|
|||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public const LETSENCRYPT_PROD = 'https://acme-v02.api.letsencrypt.org/directory';
|
||||
public const LETSENCRYPT_DEV = 'https://acme-staging-v02.api.letsencrypt.org/directory';
|
||||
public const THRESHOLD_DAYS = 30;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly StationRepository $stationRepo,
|
||||
private readonly Nginx $nginx,
|
||||
private readonly Adapters $adapters,
|
||||
|
@ -80,7 +80,7 @@ final class Acme
|
|||
$acme = new ACMECert($directoryUrl);
|
||||
|
||||
// Build LetsEncrypt settings.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$acmeEmail = $settings->getAcmeEmail();
|
||||
$acmeDomain = $settings->getAcmeDomains();
|
||||
|
@ -89,7 +89,7 @@ final class Acme
|
|||
$acmeEmail = getenv('LETSENCRYPT_EMAIL');
|
||||
if (!empty($acmeEmail)) {
|
||||
$settings->setAcmeEmail($acmeEmail);
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ final class Acme
|
|||
throw new RuntimeException('Skipping LetsEncrypt; no domain(s) set.');
|
||||
} else {
|
||||
$settings->setAcmeDomains($acmeDomain);
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Service\Avatar\AvatarServiceInterface;
|
||||
use App\Service\Avatar\Disabled;
|
||||
use App\Service\Avatar\Gravatar;
|
||||
|
@ -12,6 +12,8 @@ use App\Service\Avatar\Libravatar;
|
|||
|
||||
final class Avatar
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public const DEFAULT_SIZE = 64;
|
||||
|
||||
public const DEFAULT_AVATAR = 'https://www.azuracast.com/img/avatar.png';
|
||||
|
@ -22,14 +24,9 @@ final class Avatar
|
|||
|
||||
public const DEFAULT_SERVICE = self::SERVICE_LIBRAVATAR;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
public function getAvatarService(): AvatarServiceInterface
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
return match ($settings->getAvatarService()) {
|
||||
self::SERVICE_LIBRAVATAR => new Libravatar(),
|
||||
|
@ -42,7 +39,7 @@ final class Avatar
|
|||
{
|
||||
$avatarService = $this->getAvatarService();
|
||||
|
||||
$default = $this->settingsRepo->readSettings()->getAvatarDefaultUrl();
|
||||
$default = $this->readSettings()->getAvatarDefaultUrl();
|
||||
|
||||
if (empty($email)) {
|
||||
return $default;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace App\Service;
|
|||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Version;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -15,13 +15,13 @@ final class AzuraCastCentral
|
|||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private const BASE_URL = 'https://central.azuracast.com';
|
||||
|
||||
public function __construct(
|
||||
private readonly Version $version,
|
||||
private readonly Client $httpClient,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ final class AzuraCastCentral
|
|||
|
||||
public function getUniqueIdentifier(): string
|
||||
{
|
||||
return $this->settingsRepo->readSettings()->getAppUniqueIdentifier();
|
||||
return $this->readSettings()->getAppUniqueIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ final class AzuraCastCentral
|
|||
*/
|
||||
public function getIp(bool $cached = true): ?string
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$ip = ($cached)
|
||||
? $settings->getExternalIp()
|
||||
: null;
|
||||
|
@ -106,7 +106,7 @@ final class AzuraCastCentral
|
|||
|
||||
if (!empty($ip) && $cached) {
|
||||
$settings->setExternalIp($ip);
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Exception\RateLimitExceededException;
|
||||
use App\Lock\LockFactory;
|
||||
use App\Version;
|
||||
|
@ -16,21 +16,27 @@ use Symfony\Component\Lock\Exception\LockConflictedException;
|
|||
|
||||
final class LastFm
|
||||
{
|
||||
public const API_BASE_URL = 'https://ws.audioscrobbler.com/2.0/';
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private ?string $apiKey;
|
||||
public const API_BASE_URL = 'https://ws.audioscrobbler.com/2.0/';
|
||||
|
||||
public function __construct(
|
||||
private readonly Client $httpClient,
|
||||
private readonly LockFactory $lockFactory,
|
||||
SettingsRepository $settingsRepo
|
||||
private readonly LockFactory $lockFactory
|
||||
) {
|
||||
$this->apiKey = $settingsRepo->readSettings()->getLastFmApiKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApiKey(): ?string
|
||||
{
|
||||
return $this->readSettings()->getLastFmApiKey();
|
||||
}
|
||||
|
||||
public function hasApiKey(): bool
|
||||
{
|
||||
return !empty($this->apiKey);
|
||||
return !empty($this->getApiKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +49,7 @@ final class LastFm
|
|||
string $apiMethod,
|
||||
array $query = []
|
||||
): array {
|
||||
$apiKey = $this->apiKey;
|
||||
$apiKey = $this->getApiKey();
|
||||
if (empty($apiKey)) {
|
||||
throw new InvalidArgumentException('No last.fm API key provided.');
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use Symfony\Component\Mailer\Envelope;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Address;
|
||||
|
@ -13,20 +13,21 @@ use Symfony\Component\Mime\RawMessage;
|
|||
|
||||
final class Mail implements MailerInterface
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly MailerInterface $mailer
|
||||
) {
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->settingsRepo->readSettings()->getMailEnabled();
|
||||
return $this->readSettings()->getMailEnabled();
|
||||
}
|
||||
|
||||
public function createMessage(): Email
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$email = new Email();
|
||||
$email->from(new Address($settings->getMailSenderEmail(), $settings->getMailSenderName()));
|
||||
|
|
|
@ -7,10 +7,10 @@ namespace App\Sync\NowPlaying\Task;
|
|||
use App\Cache\NowPlayingCache;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Api\NowPlaying\NowPlaying;
|
||||
use App\Entity\ApiGenerator\NowPlayingApiGenerator;
|
||||
use App\Entity\Repository\ListenerRepository;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use App\Event\Radio\GenerateRawNowPlaying;
|
||||
|
@ -31,6 +31,7 @@ final class NowPlayingTask implements NowPlayingTaskInterface, EventSubscriberIn
|
|||
{
|
||||
use LoggerAwareTrait;
|
||||
use EntityManagerAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Adapters $adapters,
|
||||
|
@ -39,7 +40,6 @@ final class NowPlayingTask implements NowPlayingTaskInterface, EventSubscriberIn
|
|||
private readonly MessageBus $messageBus,
|
||||
private readonly RouterInterface $router,
|
||||
private readonly ListenerRepository $listenerRepo,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly NowPlayingApiGenerator $nowPlayingApiGenerator,
|
||||
private readonly HlsListeners $hlsListeners,
|
||||
) {
|
||||
|
|
|
@ -5,18 +5,18 @@ declare(strict_types=1);
|
|||
namespace App\Sync\Task;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
|
||||
final class CheckUpdatesTask extends AbstractTask
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private const UPDATE_THRESHOLD = 3780;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AzuraCastCentral $azuracastCentral
|
||||
) {
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ final class CheckUpdatesTask extends AbstractTask
|
|||
|
||||
public function run(bool $force = false): void
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
if (!$force) {
|
||||
$update_last_run = $settings->getUpdateLastRun();
|
||||
|
@ -60,6 +60,6 @@ final class CheckUpdatesTask extends AbstractTask
|
|||
}
|
||||
|
||||
$settings->updateUpdateLastRun();
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Sync\Task;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Repository\ListenerRepository;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\SongHistoryRepository;
|
||||
use App\Entity\Repository\StationQueueRepository;
|
||||
use App\Entity\StationQueue;
|
||||
|
||||
final class CleanupHistoryTask extends AbstractTask
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly SongHistoryRepository $historyRepo,
|
||||
private readonly StationQueueRepository $queueRepo,
|
||||
private readonly ListenerRepository $listenerRepo,
|
||||
|
@ -31,7 +32,7 @@ final class CleanupHistoryTask extends AbstractTask
|
|||
$this->queueRepo->cleanup(StationQueue::DAYS_TO_KEEP);
|
||||
|
||||
// Clean up history and listeners according to user settings.
|
||||
$daysToKeep = $this->settingsRepo->readSettings()->getHistoryKeepDays();
|
||||
$daysToKeep = $this->readSettings()->getHistoryKeepDays();
|
||||
if (0 !== $daysToKeep) {
|
||||
$this->historyRepo->cleanup($daysToKeep);
|
||||
$this->listenerRepo->cleanup($daysToKeep);
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Sync\Task;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Enums\StorageLocationTypes;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\StorageLocationRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StorageLocation;
|
||||
|
@ -18,8 +18,9 @@ use Throwable;
|
|||
|
||||
final class RotateLogsTask extends AbstractTask
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly StorageLocationRepository $storageLocationRepo,
|
||||
private readonly Nginx $nginx,
|
||||
) {
|
||||
|
@ -59,7 +60,7 @@ final class RotateLogsTask extends AbstractTask
|
|||
}
|
||||
|
||||
// Rotate the automated backups.
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
$copiesToKeep = $settings->getBackupKeepCopies();
|
||||
if ($copiesToKeep > 0) {
|
||||
|
|
|
@ -4,20 +4,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Sync\Task;
|
||||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\Analytics;
|
||||
use App\Entity\Enums\AnalyticsIntervals;
|
||||
use App\Entity\Enums\AnalyticsLevel;
|
||||
use App\Entity\Repository\AnalyticsRepository;
|
||||
use App\Entity\Repository\ListenerRepository;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\SongHistoryRepository;
|
||||
use App\Entity\Station;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
final class RunAnalyticsTask extends AbstractTask
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly AnalyticsRepository $analyticsRepo,
|
||||
private readonly ListenerRepository $listenerRepo,
|
||||
private readonly SongHistoryRepository $historyRepo,
|
||||
|
@ -36,7 +37,7 @@ final class RunAnalyticsTask extends AbstractTask
|
|||
|
||||
public function run(bool $force = false): void
|
||||
{
|
||||
switch ($this->settingsRepo->readSettings()->getAnalytics()) {
|
||||
switch ($this->readSettings()->getAnalytics()) {
|
||||
case AnalyticsLevel::None:
|
||||
$this->purgeListeners();
|
||||
$this->purgeAnalytics();
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Sync\Task;
|
||||
|
||||
use App\Console\Application;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Entity\StationSchedule;
|
||||
use App\Message;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
@ -14,10 +14,11 @@ use Symfony\Component\Messenger\MessageBus;
|
|||
|
||||
final class RunBackupTask extends AbstractTask
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly MessageBus $messageBus,
|
||||
private readonly Application $console,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -34,10 +35,10 @@ final class RunBackupTask extends AbstractTask
|
|||
public function __invoke(Message\AbstractMessage $message): void
|
||||
{
|
||||
if ($message instanceof Message\BackupMessage) {
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->updateBackupLastRun();
|
||||
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
|
||||
[$result_code, $result_output] = $this->runBackup(
|
||||
$message->path,
|
||||
|
@ -48,9 +49,9 @@ final class RunBackupTask extends AbstractTask
|
|||
|
||||
$result_output = 'Exited with code ' . $result_code . ":\n" . $result_output;
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->setBackupLastOutput($result_output);
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,8 +89,7 @@ final class RunBackupTask extends AbstractTask
|
|||
|
||||
public function run(bool $force = false): void
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
|
||||
$settings = $this->readSettings();
|
||||
if (!$settings->getBackupEnabled()) {
|
||||
$this->logger->debug('Automated backups disabled; skipping...');
|
||||
return;
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Sync\Task;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Service\IpGeolocator\GeoLite;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -14,11 +14,12 @@ use Symfony\Component\Process\Process;
|
|||
|
||||
final class UpdateGeoLiteTask extends AbstractTask
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
private const UPDATE_THRESHOLD = 86000;
|
||||
|
||||
public function __construct(
|
||||
private readonly Client $httpClient,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
private readonly Client $httpClient
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -29,7 +30,7 @@ final class UpdateGeoLiteTask extends AbstractTask
|
|||
|
||||
public function run(bool $force = false): void
|
||||
{
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
if (!$force) {
|
||||
$lastRun = $settings->getGeoliteLastRun();
|
||||
|
@ -52,9 +53,9 @@ final class UpdateGeoLiteTask extends AbstractTask
|
|||
);
|
||||
}
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
$settings->updateGeoliteLastRun();
|
||||
$this->settingsRepo->writeSettings($settings);
|
||||
$this->writeSettings($settings);
|
||||
}
|
||||
|
||||
public function updateDatabase(string $licenseKey): void
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\VueComponent;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Adapters;
|
||||
|
@ -16,9 +16,10 @@ use Symfony\Component\Intl\Countries;
|
|||
|
||||
final class StationFormComponent implements VueComponentInterface
|
||||
{
|
||||
use SettingsAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Adapters $adapters,
|
||||
private readonly SettingsRepository $settingsRepo
|
||||
private readonly Adapters $adapters
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -26,7 +27,7 @@ final class StationFormComponent implements VueComponentInterface
|
|||
{
|
||||
$installedFrontends = $this->adapters->listFrontendAdapters(true);
|
||||
|
||||
$settings = $this->settingsRepo->readSettings();
|
||||
$settings = $this->readSettings();
|
||||
|
||||
return [
|
||||
'showAdminTab' => $request->getAcl()->isAllowed(GlobalPermissions::Stations),
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace Functional;
|
|||
|
||||
use App\Acl;
|
||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\StationRepository;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Environment;
|
||||
use App\Media\MediaProcessor;
|
||||
|
@ -17,9 +19,9 @@ abstract class CestAbstract
|
|||
|
||||
protected Environment $environment;
|
||||
|
||||
protected \App\Entity\Repository\SettingsRepository $settingsRepo;
|
||||
protected SettingsRepository $settingsRepo;
|
||||
|
||||
protected \App\Entity\Repository\StationRepository $stationRepo;
|
||||
protected StationRepository $stationRepo;
|
||||
|
||||
protected ReloadableEntityManagerInterface $em;
|
||||
|
||||
|
@ -35,8 +37,8 @@ abstract class CestAbstract
|
|||
$this->di = $tests_module->container;
|
||||
$this->em = $tests_module->em;
|
||||
|
||||
$this->settingsRepo = $this->di->get(\App\Entity\Repository\SettingsRepository::class);
|
||||
$this->stationRepo = $this->di->get(\App\Entity\Repository\StationRepository::class);
|
||||
$this->settingsRepo = $this->di->get(SettingsRepository::class);
|
||||
$this->stationRepo = $this->di->get(StationRepository::class);
|
||||
$this->environment = $this->di->get(Environment::class);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue