Add EnvironmentAwareTrait.
This commit is contained in:
parent
18ad4ad6ef
commit
cbc6a1f4fc
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Assets;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
abstract class AbstractCustomAsset implements CustomAssetInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected readonly Environment $environment,
|
||||
protected readonly ?Station $station = null
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ enum AssetTypes: string
|
|||
Environment $environment,
|
||||
?Station $station = null
|
||||
): CustomAssetInterface {
|
||||
return match ($this) {
|
||||
self::AlbumArt => new AlbumArtCustomAsset($environment, $station),
|
||||
self::Background => new BackgroundCustomAsset($environment, $station),
|
||||
self::BrowserIcon => new BrowserIconCustomAsset($environment, $station),
|
||||
$instance = match ($this) {
|
||||
self::AlbumArt => new AlbumArtCustomAsset($station),
|
||||
self::Background => new BackgroundCustomAsset($station),
|
||||
self::BrowserIcon => new BrowserIconCustomAsset($station),
|
||||
};
|
||||
$instance->setEnvironment($environment);
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\UserRepository;
|
||||
use App\Entity\User;
|
||||
use App\Exception\NotLoggedInException;
|
||||
|
@ -11,6 +12,8 @@ use Mezzio\Session\SessionInterface;
|
|||
|
||||
final class Auth
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const SESSION_IS_LOGIN_COMPLETE_KEY = 'is_login_complete';
|
||||
public const SESSION_USER_ID_KEY = 'user_id';
|
||||
public const SESSION_MASQUERADE_USER_ID_KEY = 'masquerade_user_id';
|
||||
|
@ -24,8 +27,7 @@ final class Auth
|
|||
|
||||
public function __construct(
|
||||
private readonly UserRepository $userRepo,
|
||||
private readonly SessionInterface $session,
|
||||
private readonly Environment $environment
|
||||
private readonly SessionInterface $session
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -6,19 +6,14 @@ namespace App\Console\Command;
|
|||
|
||||
use App\Console\Command\Traits\PassThruProcess;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
abstract class AbstractDatabaseCommand extends CommandAbstract
|
||||
{
|
||||
use PassThruProcess;
|
||||
use EntityManagerAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected function getDatabaseSettingsAsCliFlags(): array
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace App\Console\Command\Backup;
|
|||
|
||||
use App\Console\Command\AbstractDatabaseCommand;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -26,10 +25,9 @@ use const PATHINFO_EXTENSION;
|
|||
final class BackupCommand extends AbstractDatabaseCommand
|
||||
{
|
||||
public function __construct(
|
||||
Environment $environment,
|
||||
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
|
||||
) {
|
||||
parent::__construct($environment);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Environment;
|
||||
use App\Version;
|
||||
use OpenApi\Annotations\OpenApi;
|
||||
use OpenApi\Generator;
|
||||
|
@ -22,9 +22,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
final class GenerateApiDocsCommand extends CommandAbstract
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Version $version
|
||||
) {
|
||||
parent::__construct();
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Locale;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Enums\SupportedLocales;
|
||||
use App\Environment;
|
||||
use Gettext\Generator\PoGenerator;
|
||||
use Gettext\Loader\PoLoader;
|
||||
use Gettext\Scanner\PhpScanner;
|
||||
|
@ -26,11 +26,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class GenerateCommand extends CommandAbstract
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Locale;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Enums\SupportedLocales;
|
||||
use App\Environment;
|
||||
use Gettext\Generator\MoGenerator;
|
||||
use Gettext\Loader\PoLoader;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
|
@ -21,11 +21,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class ImportCommand extends CommandAbstract
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace App\Console\Command\MessageQueue;
|
|||
|
||||
use App\CallableEventDispatcherInterface;
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Doctrine\Messenger\ClearEntityManagerSubscriber;
|
||||
use App\Environment;
|
||||
use App\MessageQueue\LogWorkerExceptionSubscriber;
|
||||
use App\MessageQueue\QueueManagerInterface;
|
||||
use App\MessageQueue\ResetArrayCacheSubscriber;
|
||||
|
@ -33,12 +33,12 @@ use Throwable;
|
|||
final class ProcessCommand extends CommandAbstract
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly MessageBus $messageBus,
|
||||
private readonly CallableEventDispatcherInterface $eventDispatcher,
|
||||
private readonly QueueManagerInterface $queueManager,
|
||||
private readonly Environment $environment,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Environment;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -16,11 +17,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class MigrateConfigCommand extends CommandAbstract
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -19,8 +19,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
)]
|
||||
final class SetupCommand extends CommandAbstract
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
||||
private readonly AzuraCastCentral $acCentral,
|
||||
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace App\Console\Command;
|
|||
|
||||
use App\Container\ContainerAwareTrait;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
||||
|
@ -25,12 +25,7 @@ final class SetupFixturesCommand extends CommandAbstract
|
|||
{
|
||||
use ContainerAwareTrait;
|
||||
use EntityManagerAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Sync;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Environment;
|
||||
use App\Lock\LockFactory;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Lock\Lock;
|
||||
|
@ -17,12 +17,12 @@ use function random_int;
|
|||
abstract class AbstractSyncCommand extends CommandAbstract
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
protected array $processes = [];
|
||||
|
||||
public function __construct(
|
||||
protected LockFactory $lockFactory,
|
||||
protected Environment $environment,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace App\Console\Command\Sync;
|
|||
use App\Cache\NowPlayingCache;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Environment;
|
||||
use App\Lock\LockFactory;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -31,9 +30,8 @@ final class NowPlayingCommand extends AbstractSyncCommand
|
|||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly NowPlayingCache $nowPlayingCache,
|
||||
LockFactory $lockFactory,
|
||||
Environment $environment
|
||||
) {
|
||||
parent::__construct($lockFactory, $environment);
|
||||
parent::__construct($lockFactory);
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace App\Console\Command\Sync;
|
||||
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Environment;
|
||||
use App\Event\GetSyncTasks;
|
||||
use App\Lock\LockFactory;
|
||||
use App\Sync\Task\AbstractTask;
|
||||
|
@ -27,12 +26,11 @@ use function usleep;
|
|||
final class RunnerCommand extends AbstractSyncCommand
|
||||
{
|
||||
public function __construct(
|
||||
LockFactory $lockFactory,
|
||||
Environment $environment,
|
||||
private readonly EventDispatcherInterface $dispatcher,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
LockFactory $lockFactory
|
||||
) {
|
||||
parent::__construct($lockFactory, $environment);
|
||||
parent::__construct($lockFactory);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Container;
|
||||
|
||||
use App\Environment;
|
||||
use DI\Attribute\Inject;
|
||||
|
||||
trait EnvironmentAwareTrait
|
||||
{
|
||||
protected Environment $environment;
|
||||
|
||||
#[Inject]
|
||||
public function setEnvironment(Environment $environment): void
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function getEnvironment(): Environment
|
||||
{
|
||||
return $this->environment;
|
||||
}
|
||||
}
|
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class BackupsAction
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Version;
|
||||
|
@ -11,9 +11,10 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class UpdatesAction
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly Environment $environment,
|
||||
private readonly Version $version
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -5,18 +5,15 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Admin\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class DeleteCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -5,17 +5,14 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Admin\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class GetCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Admin\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Media\AlbumArt;
|
||||
|
@ -15,10 +15,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class PostCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Controller\Api\Traits\HasLogViewer;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
|
@ -15,9 +15,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||
final class LogsAction
|
||||
{
|
||||
use HasLogViewer;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly ServiceControl $serviceControl,
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin;
|
||||
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\OpenApi;
|
||||
|
@ -37,10 +37,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||
]
|
||||
final class ServerStatsAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin\Shoutcast;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\Flow;
|
||||
|
@ -15,10 +15,7 @@ use Symfony\Component\Process\Process;
|
|||
|
||||
final class PostAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -4,21 +4,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Api\Admin\Stations;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Controller\Api\Admin\StationsController;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Configuration;
|
||||
use DeepCopy;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Throwable;
|
||||
|
||||
final class CloneAction extends StationsController
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const CLONE_MEDIA_STORAGE = 'media_storage';
|
||||
public const CLONE_RECORDINGS_STORAGE = 'recordings_storage';
|
||||
public const CLONE_PODCASTS_STORAGE = 'podcasts_storage';
|
||||
|
@ -30,25 +29,6 @@ final class CloneAction extends StationsController
|
|||
public const CLONE_PERMISSIONS = 'permissions';
|
||||
public const CLONE_WEBHOOKS = 'webhooks';
|
||||
|
||||
public function __construct(
|
||||
Entity\Repository\StationRepository $stationRepo,
|
||||
Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
||||
Entity\Repository\StationQueueRepository $queueRepo,
|
||||
Configuration $configuration,
|
||||
Serializer $serializer,
|
||||
ValidatorInterface $validator,
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
parent::__construct(
|
||||
$stationRepo,
|
||||
$storageLocationRepo,
|
||||
$queueRepo,
|
||||
$configuration,
|
||||
$serializer,
|
||||
$validator
|
||||
);
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
|
|
|
@ -5,18 +5,15 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Stations\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class DeleteCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -5,17 +5,14 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Stations\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class GetCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Api\Stations\CustomAssets;
|
||||
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Media\AlbumArt;
|
||||
|
@ -15,10 +15,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class PostCustomAssetAction
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
|
|
|
@ -6,10 +6,10 @@ namespace App\Controller\Api\Stations;
|
|||
|
||||
use App;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Controller\Api\Traits\AcceptsDateRange;
|
||||
use App\Doctrine\ReadOnlyBatchIteratorAggregate;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\OpenApi;
|
||||
|
@ -63,10 +63,10 @@ final class HistoryController
|
|||
{
|
||||
use AcceptsDateRange;
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Entity\ApiGenerator\SongHistoryApiGenerator $songHistoryApiGenerator,
|
||||
private readonly Environment $environment
|
||||
private readonly Entity\ApiGenerator\SongHistoryApiGenerator $songHistoryApiGenerator
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Controller\Frontend;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception\NotLoggedInException;
|
||||
use App\Exception\ValidationException;
|
||||
use App\Http\Response;
|
||||
|
@ -21,10 +21,10 @@ use Throwable;
|
|||
final class SetupController
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
||||
private readonly Environment $environment,
|
||||
private readonly Entity\Repository\RolePermissionRepository $permissionRepo,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly StationFormComponent $stationFormComponent,
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Service\AzuraCastCentral;
|
||||
|
@ -12,8 +12,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
final class SftpUsersAction
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly AzuraCastCentral $acCentral
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Assets\BackgroundCustomAsset;
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Assets\BrowserIconCustomAsset;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Enums\SupportedLocales;
|
||||
use App\Enums\SupportedThemes;
|
||||
|
@ -16,6 +17,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||
final class Customization
|
||||
{
|
||||
use RequestAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
private ?Entity\User $user;
|
||||
|
||||
|
@ -30,7 +32,6 @@ final class Customization
|
|||
private string $instanceName;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
$this->settings = $settingsRepo->readSettings();
|
||||
|
@ -121,7 +122,7 @@ final class Customization
|
|||
{
|
||||
$publicCss = $this->settings->getPublicCustomCss() ?? '';
|
||||
|
||||
$background = new BackgroundCustomAsset($this->environment);
|
||||
$background = AssetTypes::Background->createObject($this->environment);
|
||||
if ($background->isUploaded()) {
|
||||
$backgroundUrl = $background->getUrl();
|
||||
|
||||
|
@ -139,7 +140,8 @@ final class Customization
|
|||
{
|
||||
$publicCss = $station->getBrandingConfig()->getPublicCustomCss() ?? '';
|
||||
|
||||
$background = new BackgroundCustomAsset($this->environment, $station);
|
||||
$background = AssetTypes::Background->createObject($this->environment, $station);
|
||||
|
||||
if ($background->isUploaded()) {
|
||||
$backgroundUrl = $background->getUrl();
|
||||
|
||||
|
@ -176,7 +178,10 @@ final class Customization
|
|||
|
||||
public function getBrowserIconUrl(int $size = 256): string
|
||||
{
|
||||
return (new BrowserIconCustomAsset($this->environment))->getUrlForSize($size);
|
||||
/** @var BrowserIconCustomAsset $browserIcon */
|
||||
$browserIcon = AssetTypes::BrowserIcon->createObject($this->environment);
|
||||
|
||||
return $browserIcon->getUrlForSize($size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Repository;
|
||||
|
||||
use App\Assets\AlbumArtCustomAsset;
|
||||
use App\Assets\AssetTypes;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Flysystem\ExtendedFilesystemInterface;
|
||||
use App\Flysystem\StationFilesystems;
|
||||
use App\Radio\Enums\StreamFormats;
|
||||
|
@ -21,10 +21,11 @@ use Psr\Http\Message\UriInterface;
|
|||
*/
|
||||
final class StationRepository extends Repository
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
ReloadableEntityManagerInterface $em,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
parent::__construct($em);
|
||||
}
|
||||
|
@ -188,7 +189,7 @@ final class StationRepository extends Repository
|
|||
public function getDefaultAlbumArtUrl(?Entity\Station $station = null): UriInterface
|
||||
{
|
||||
if (null !== $station) {
|
||||
$stationAlbumArt = new AlbumArtCustomAsset($this->environment, $station);
|
||||
$stationAlbumArt = AssetTypes::AlbumArt->createObject($this->environment, $station);
|
||||
if ($stationAlbumArt->isUploaded()) {
|
||||
return $stationAlbumArt->getUri();
|
||||
}
|
||||
|
@ -200,7 +201,7 @@ final class StationRepository extends Repository
|
|||
}
|
||||
|
||||
$customUrl = $this->settingsRepo->readSettings()->getDefaultAlbumArtUrlAsUri();
|
||||
return $customUrl ?? (new AlbumArtCustomAsset($this->environment))->getUri();
|
||||
return $customUrl ?? AssetTypes::AlbumArt->createObject($this->environment)->getUri();
|
||||
}
|
||||
|
||||
public function setFallback(
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\StorageLocationAdapter;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Enums\StorageLocationAdapters;
|
||||
use App\Environment;
|
||||
use App\Flysystem\Adapter\LocalAdapterInterface;
|
||||
use App\Flysystem\Adapter\LocalFilesystemAdapter;
|
||||
use App\Flysystem\ExtendedFilesystemInterface;
|
||||
|
@ -14,10 +14,7 @@ use Symfony\Component\Filesystem\Path;
|
|||
|
||||
final class LocalStorageLocationAdapter extends AbstractStorageLocationLocationAdapter
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function getType(): StorageLocationAdapters
|
||||
{
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Enums\SupportedLocales;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Exception\NotLoggedInException;
|
||||
use App\Exception\PermissionDeniedException;
|
||||
|
@ -26,6 +26,8 @@ use Whoops\Run;
|
|||
|
||||
final class ErrorHandler extends \Slim\Handlers\ErrorHandler
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
private bool $returnJson = false;
|
||||
|
||||
private bool $showDetailed = false;
|
||||
|
@ -36,7 +38,6 @@ final class ErrorHandler extends \Slim\Handlers\ErrorHandler
|
|||
private readonly View $view,
|
||||
private readonly Router $router,
|
||||
private readonly InjectSession $injectSession,
|
||||
private readonly Environment $environment,
|
||||
App $app,
|
||||
Logger $logger,
|
||||
) {
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Installer\Command;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Enums\SupportedLocales;
|
||||
use App\Environment;
|
||||
use App\Installer\EnvFiles\AbstractEnvFile;
|
||||
|
@ -26,13 +27,9 @@ use Symfony\Component\Yaml\Yaml;
|
|||
)]
|
||||
final class InstallCommand extends Command
|
||||
{
|
||||
public const DEFAULT_BASE_DIRECTORY = '/installer';
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
public const DEFAULT_BASE_DIRECTORY = '/installer';
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
|
|
|
@ -5,9 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Middleware\Auth;
|
||||
|
||||
use App\Acl;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Customization;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -16,9 +16,10 @@ use Psr\Http\Server\RequestHandlerInterface;
|
|||
|
||||
abstract class AbstractAuth implements MiddlewareInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected readonly Entity\Repository\UserRepository $userRepo,
|
||||
protected readonly Environment $environment,
|
||||
protected readonly Acl $acl,
|
||||
protected readonly Customization $customization
|
||||
) {
|
||||
|
|
|
@ -8,7 +8,6 @@ use App\Acl;
|
|||
use App\Auth;
|
||||
use App\Customization;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception\CsrfValidationException;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Security\SplitToken;
|
||||
|
@ -24,11 +23,10 @@ final class ApiAuth extends AbstractAuth
|
|||
public function __construct(
|
||||
protected Entity\Repository\ApiKeyRepository $apiKeyRepo,
|
||||
Entity\Repository\UserRepository $userRepo,
|
||||
Environment $environment,
|
||||
Acl $acl,
|
||||
Customization $customization
|
||||
) {
|
||||
parent::__construct($userRepo, $environment, $acl, $customization);
|
||||
parent::__construct($userRepo, $acl, $customization);
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
|
@ -56,8 +54,8 @@ final class ApiAuth extends AbstractAuth
|
|||
$auth = new Auth(
|
||||
userRepo: $this->userRepo,
|
||||
session: $request->getAttribute(ServerRequest::ATTR_SESSION),
|
||||
environment: $this->environment,
|
||||
);
|
||||
$auth->setEnvironment($this->environment);
|
||||
|
||||
if ($auth->isLoggedIn()) {
|
||||
$user = $auth->getLoggedInUser();
|
||||
|
|
|
@ -18,8 +18,9 @@ final class StandardAuth extends AbstractAuth
|
|||
$auth = new Auth(
|
||||
userRepo: $this->userRepo,
|
||||
session: $request->getAttribute(ServerRequest::ATTR_SESSION),
|
||||
environment: $this->environment,
|
||||
);
|
||||
$auth->setEnvironment($this->environment);
|
||||
|
||||
$user = ($auth->isLoggedIn()) ? $auth->getLoggedInUser() : null;
|
||||
|
||||
$request = $request
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace App\Middleware;
|
|||
|
||||
use App\Acl;
|
||||
use App\Auth;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Customization;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -20,9 +20,10 @@ use Psr\Http\Server\RequestHandlerInterface;
|
|||
*/
|
||||
final class GetCurrentUser implements MiddlewareInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Entity\Repository\UserRepository $userRepo,
|
||||
private readonly Environment $environment,
|
||||
private readonly Acl $acl,
|
||||
private readonly Customization $customization
|
||||
) {
|
||||
|
@ -34,8 +35,9 @@ final class GetCurrentUser implements MiddlewareInterface
|
|||
$auth = new Auth(
|
||||
userRepo: $this->userRepo,
|
||||
session: $request->getAttribute(ServerRequest::ATTR_SESSION),
|
||||
environment: $this->environment,
|
||||
);
|
||||
$auth->setEnvironment($this->environment);
|
||||
|
||||
$user = ($auth->isLoggedIn()) ? $auth->getLoggedInUser() : null;
|
||||
|
||||
$request = $request
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware\Module;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Utilities\Urls;
|
||||
|
@ -21,9 +21,10 @@ use Symfony\Component\VarDumper\VarDumper;
|
|||
*/
|
||||
final class Api
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
||||
private readonly Environment $environment
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Doctrine\DecoratedEntityManager;
|
||||
use App\Environment;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
@ -13,9 +13,10 @@ use Psr\Http\Server\RequestHandlerInterface;
|
|||
|
||||
final class ReopenEntityManagerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly DecoratedEntityManager $em,
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -4,18 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Api\Notification;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Environment;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Session\FlashLevels;
|
||||
|
||||
final class ProfilerAdvisorCheck
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __invoke(GetNotifications $event): void
|
||||
{
|
||||
|
|
|
@ -4,17 +4,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Notification\Check;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Enums\GlobalPermissions;
|
||||
use App\Environment;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Session\FlashLevels;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
final class RecentBackupCheck
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Radio;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception\Supervisor\AlreadyRunningException;
|
||||
use App\Exception\Supervisor\NotRunningException;
|
||||
use App\Exception\SupervisorException;
|
||||
|
@ -21,9 +21,9 @@ abstract class AbstractLocalAdapter
|
|||
{
|
||||
use LoggerAwareTrait;
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected SupervisorInterface $supervisor,
|
||||
protected EventDispatcherInterface $dispatcher,
|
||||
protected Router $router,
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Radio\Backend\Liquidsoap;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\Radio\WriteLiquidsoapConfiguration;
|
||||
use App\Radio\Backend\Liquidsoap;
|
||||
use App\Radio\Enums\AudioProcessingMethods;
|
||||
|
@ -22,10 +22,11 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
|
||||
final class ConfigWriter implements EventSubscriberInterface
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
||||
private readonly Liquidsoap $liquidsoap,
|
||||
private readonly Environment $environment,
|
||||
private readonly FallbackFile $fallbackFile
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ declare(strict_types=1);
|
|||
namespace App\Radio;
|
||||
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Enums\PlaylistTypes;
|
||||
use App\Entity\Repository\StationPlaylistMediaRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationPlaylist;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Radio\Enums\BackendAdapters;
|
||||
use App\Radio\Enums\FrontendAdapters;
|
||||
|
@ -20,6 +20,7 @@ use Supervisor\SupervisorInterface;
|
|||
final class Configuration
|
||||
{
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const DEFAULT_PORT_MIN = 8000;
|
||||
public const DEFAULT_PORT_MAX = 8499;
|
||||
|
@ -36,7 +37,6 @@ final class Configuration
|
|||
public function __construct(
|
||||
private readonly Adapters $adapters,
|
||||
private readonly SupervisorInterface $supervisor,
|
||||
private readonly Environment $environment,
|
||||
private readonly StationPlaylistMediaRepository $spmRepo,
|
||||
) {
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ final class Configuration
|
|||
*/
|
||||
public function removeConfiguration(Station $station): void
|
||||
{
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
if ($this->environment->isTesting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Radio;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Flysystem\StationFilesystems;
|
||||
|
||||
final class FallbackFile
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function getFallbackPathForStation(Entity\Station $station): string
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Router;
|
||||
use App\Nginx\CustomUrls;
|
||||
use App\Radio\AbstractLocalAdapter;
|
||||
|
@ -29,12 +28,11 @@ abstract class AbstractFrontend extends AbstractLocalAdapter
|
|||
protected Client $http_client,
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo,
|
||||
protected Entity\Repository\StationMountRepository $stationMountRepo,
|
||||
Environment $environment,
|
||||
SupervisorInterface $supervisor,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
Router $router
|
||||
) {
|
||||
parent::__construct($environment, $supervisor, $dispatcher, $router);
|
||||
parent::__construct($supervisor, $dispatcher, $router);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace App\Radio\Remote;
|
||||
|
||||
use App\Cache\AzuraRelayCache;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Promise\Create;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
|
@ -18,6 +18,8 @@ use NowPlaying\Result\Result;
|
|||
|
||||
final class AzuraRelay extends AbstractRemote
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly AzuraRelayCache $azuraRelayCache,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
|
@ -91,7 +93,7 @@ final class AzuraRelay extends AbstractRemote
|
|||
if (
|
||||
$use_radio_proxy
|
||||
|| 'https' === $base_url->getScheme()
|
||||
|| (!Environment::getInstance()->isProduction() && !Environment::getInstance()->isDocker())
|
||||
|| (!$this->environment->isProduction() && !$this->environment->isDocker())
|
||||
) {
|
||||
// Web proxy support.
|
||||
return (string)$base_url
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Lock\LockFactory;
|
||||
|
@ -14,11 +15,12 @@ use Symfony\Component\RateLimiter\Storage\CacheStorage;
|
|||
|
||||
final class RateLimit
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
private CacheItemPoolInterface $psr6Cache;
|
||||
|
||||
public function __construct(
|
||||
private readonly LockFactory $lockFactory,
|
||||
private readonly Environment $environment,
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
CacheItemPoolInterface $cacheItemPool
|
||||
) {
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Entity\Repository\StationRepository;
|
||||
|
@ -22,6 +23,7 @@ use Symfony\Component\Filesystem\Filesystem;
|
|||
final class Acme
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const LETSENCRYPT_PROD = 'https://acme-v02.api.letsencrypt.org/directory';
|
||||
public const LETSENCRYPT_DEV = 'https://acme-staging-v02.api.letsencrypt.org/directory';
|
||||
|
@ -30,7 +32,6 @@ final class Acme
|
|||
public function __construct(
|
||||
private readonly SettingsRepository $settingsRepo,
|
||||
private readonly StationRepository $stationRepo,
|
||||
private readonly Environment $environment,
|
||||
private readonly Nginx $nginx,
|
||||
private readonly Adapters $adapters,
|
||||
) {
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Version;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -14,11 +14,11 @@ use GuzzleHttp\Client;
|
|||
final class AzuraCastCentral
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
private const BASE_URL = 'https://central.azuracast.com';
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Version $version,
|
||||
private readonly Client $httpClient,
|
||||
private readonly Entity\Repository\SettingsRepository $settingsRepo
|
||||
|
|
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
final class Centrifugo
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const GLOBAL_TIME_CHANNEL = 'global:time';
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Client $client,
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -4,16 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use Redis;
|
||||
use RuntimeException;
|
||||
|
||||
final class RedisFactory
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Environment $environment
|
||||
) {
|
||||
}
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function isSupported(): bool
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Exception\SupervisorException;
|
||||
use App\Service\ServiceControl\ServiceData;
|
||||
use Supervisor\Exception\Fault\BadNameException;
|
||||
|
@ -15,9 +15,10 @@ use Supervisor\SupervisorInterface;
|
|||
|
||||
final class ServiceControl
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly SupervisorInterface $supervisor,
|
||||
private readonly Environment $environment,
|
||||
private readonly Centrifugo $centrifugo
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Environment;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
|
||||
final class WebUpdater
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
// Don't worry that this is insecure; it's only ever used for internal communications.
|
||||
public const WATCHTOWER_TOKEN = 'azur4c457';
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly GuzzleFactory $guzzleFactory
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Sync\Task;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
|
||||
final class CheckUpdatesTask extends AbstractTask
|
||||
{
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
private const UPDATE_THRESHOLD = 3780;
|
||||
|
||||
public function __construct(
|
||||
|
@ -37,7 +39,7 @@ final class CheckUpdatesTask extends AbstractTask
|
|||
}
|
||||
}
|
||||
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
if ($this->environment->isTesting()) {
|
||||
$this->logger->info('Update checks are currently disabled for this AzuraCast instance.');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ namespace App\Webhook;
|
|||
|
||||
use App\Container\ContainerAwareTrait;
|
||||
use App\Container\EntityManagerAwareTrait;
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity\ApiGenerator\NowPlayingApiGenerator;
|
||||
use App\Entity\Station;
|
||||
use App\Entity\StationWebhook;
|
||||
use App\Environment;
|
||||
use App\Http\RouterInterface;
|
||||
use App\Message;
|
||||
use App\Webhook\Connector\AbstractConnector;
|
||||
|
@ -23,9 +23,9 @@ final class Dispatcher
|
|||
use LoggerAwareTrait;
|
||||
use ContainerAwareTrait;
|
||||
use EntityManagerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly RouterInterface $router,
|
||||
private readonly LocalWebhookHandler $localHandler,
|
||||
private readonly NowPlayingApiGenerator $nowPlayingApiGen
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Webhook;
|
||||
|
||||
use App\Container\EnvironmentAwareTrait;
|
||||
use App\Container\LoggerAwareTrait;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Service\Centrifugo;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
|
@ -15,11 +15,11 @@ use const JSON_PRETTY_PRINT;
|
|||
final class LocalWebhookHandler
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
use EnvironmentAwareTrait;
|
||||
|
||||
public const NAME = 'local';
|
||||
|
||||
public function __construct(
|
||||
private readonly Environment $environment,
|
||||
private readonly Centrifugo $centrifugo
|
||||
) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue