Settings refactor part 1: Rename App\Settings to App\Environment.
Previously AzuraCast had two very similar `$settings` variables, one that was from environment and the other from the database. This refactor distinguishes the two much more clearly.
This commit is contained in:
parent
58a16112cf
commit
5727f12b6f
|
@ -6,7 +6,7 @@ ini_set('display_errors', 1);
|
|||
$autoloader = require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
$app = App\AppFactory::create($autoloader, [
|
||||
App\Settings::BASE_DIR => dirname(__DIR__),
|
||||
App\Environment::BASE_DIR => dirname(__DIR__),
|
||||
]);
|
||||
|
||||
$di = $app->getContainer();
|
||||
|
@ -15,4 +15,4 @@ App\Customization::initCli();
|
|||
|
||||
/** @var App\Console\Application $cli */
|
||||
$cli = $di->get(App\Console\Application::class);
|
||||
$cli->run();
|
||||
$cli->run();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Customization;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ return [
|
|||
'files' => [
|
||||
'js' => [
|
||||
[
|
||||
'src' => 'dist/lib/vue/' . (Settings::getInstance()->isProduction() ? 'vue.min.js' : 'vue.js'),
|
||||
'src' => 'dist/lib/vue/' . (Environment::getInstance()->isProduction() ? 'vue.min.js' : 'vue.js'),
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use App\Console\Application;
|
||||
use App\Console\Command;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
return function (Application $console) {
|
||||
// Set console version and name.
|
||||
|
@ -11,10 +11,10 @@ return function (Application $console) {
|
|||
/** @var App\Version $version */
|
||||
$version = $di->get(App\Version::class);
|
||||
|
||||
/** @var Settings $settings */
|
||||
$settings = $di->get(Settings::class);
|
||||
/** @var Environment $environment */
|
||||
$environment = $di->get(Environment::class);
|
||||
|
||||
$console->setName($settings[Settings::APP_NAME] . ' Command Line Tools (' . $settings[Settings::APP_ENV] . ')');
|
||||
$console->setName($environment[Environment::APP_NAME] . ' Command Line Tools (' . $environment[Environment::APP_ENV] . ')');
|
||||
$console->setVersion($version->getVersion());
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Environment;
|
||||
use App\Event;
|
||||
use App\Middleware;
|
||||
use App\Settings;
|
||||
|
||||
return function (App\EventDispatcher $dispatcher) {
|
||||
$dispatcher->addListener(Event\BuildConsoleCommands::class,
|
||||
|
@ -11,15 +11,15 @@ return function (App\EventDispatcher $dispatcher) {
|
|||
$console = $event->getConsole();
|
||||
$di = $console->getContainer();
|
||||
|
||||
/** @var Settings $settings */
|
||||
$settings = $di->get(Settings::class);
|
||||
/** @var Environment $environment */
|
||||
$environment = $di->get(Environment::class);
|
||||
|
||||
if ($settings->enableRedis()) {
|
||||
if ($environment->enableRedis()) {
|
||||
$console->command('cache:clear', Command\ClearCacheCommand::class)
|
||||
->setDescription('Clear all application caches.');
|
||||
}
|
||||
|
||||
if ($settings->enableDatabase()) {
|
||||
if ($environment->enableDatabase()) {
|
||||
// Doctrine ORM/DBAL
|
||||
Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($console);
|
||||
|
||||
|
@ -34,7 +34,7 @@ return function (App\EventDispatcher $dispatcher) {
|
|||
|
||||
$migrationConfigurations = [
|
||||
'migrations_paths' => [
|
||||
'App\Entity\Migration' => $settings[Settings::BASE_DIR] . '/src/Entity/Migration',
|
||||
'App\Entity\Migration' => $environment->getBaseDirectory() . '/src/Entity/Migration',
|
||||
],
|
||||
'table_storage' => [
|
||||
'table_name' => 'app_migrations',
|
||||
|
@ -44,7 +44,7 @@ return function (App\EventDispatcher $dispatcher) {
|
|||
|
||||
$buildMigrationConfigurationsEvent = new Event\BuildMigrationConfigurationArray(
|
||||
$migrationConfigurations,
|
||||
$settings[Settings::BASE_DIR]
|
||||
$environment->getBaseDirectory()
|
||||
);
|
||||
$dispatcher->dispatch($buildMigrationConfigurationsEvent);
|
||||
|
||||
|
@ -68,8 +68,8 @@ return function (App\EventDispatcher $dispatcher) {
|
|||
// Load app-specific route configuration.
|
||||
$container = $app->getContainer();
|
||||
|
||||
/** @var Settings $settings */
|
||||
$settings = $container->get(Settings::class);
|
||||
/** @var Environment $environment */
|
||||
$environment = $container->get(Environment::class);
|
||||
|
||||
call_user_func(include(__DIR__ . '/routes.php'), $app);
|
||||
|
||||
|
@ -102,7 +102,7 @@ return function (App\EventDispatcher $dispatcher) {
|
|||
$app->add(Middleware\InjectSession::class);
|
||||
|
||||
// Add an error handler for most in-controller/task situations.
|
||||
$errorMiddleware = $app->addErrorMiddleware(!$settings->isProduction(), true, true);
|
||||
$errorMiddleware = $app->addErrorMiddleware(!$environment->isProduction(), true, true);
|
||||
$errorMiddleware->setDefaultErrorHandler(Slim\Interfaces\ErrorHandlerInterface::class);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* @var App\Settings $settings
|
||||
* @var App\Environment $settings
|
||||
* @var App\Version $version
|
||||
*/
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ return function (App\Event\BuildStationMenu $e) {
|
|||
$backend = $e->getStationBackend();
|
||||
$frontend = $e->getStationFrontend();
|
||||
|
||||
$settings = $e->getSettings();
|
||||
$settings = $e->getEnvironment();
|
||||
|
||||
$e->merge([
|
||||
'start_station' => [
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
* PHP-DI Services
|
||||
*/
|
||||
|
||||
use App\Environment;
|
||||
use App\Event;
|
||||
use App\Settings;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
|
||||
// URL Router helper
|
||||
App\Http\Router::class => function (
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Slim\App $app,
|
||||
App\Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
|
@ -57,7 +57,7 @@ return [
|
|||
App\Doctrine\DecoratedEntityManager::class => function (
|
||||
Doctrine\Common\Cache\Cache $doctrineCache,
|
||||
Doctrine\Common\Annotations\Reader $reader,
|
||||
Settings $settings,
|
||||
Environment $environment,
|
||||
App\Doctrine\Event\StationRequiresRestart $eventRequiresRestart,
|
||||
App\Doctrine\Event\AuditLog $eventAuditLog,
|
||||
App\EventDispatcher $dispatcher
|
||||
|
@ -81,7 +81,7 @@ return [
|
|||
'platform' => new Doctrine\DBAL\Platforms\MariaDb1027Platform(),
|
||||
];
|
||||
|
||||
if (!$settings[Settings::IS_DOCKER]) {
|
||||
if (!$environment->isDocker()) {
|
||||
$connectionOptions['host'] = $_ENV['db_host'] ?? 'localhost';
|
||||
$connectionOptions['port'] = $_ENV['db_port'] ?? '3306';
|
||||
$connectionOptions['dbname'] = $_ENV['db_name'] ?? 'azuracast';
|
||||
|
@ -93,15 +93,15 @@ return [
|
|||
// Fetch and store entity manager.
|
||||
$config = Doctrine\ORM\Tools\Setup::createConfiguration(
|
||||
Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS,
|
||||
$settings->getTempDirectory() . '/proxies',
|
||||
$environment->getTempDirectory() . '/proxies',
|
||||
$doctrineCache
|
||||
);
|
||||
|
||||
$mappingClassesPaths = [$settings->getBaseDirectory() . '/src/Entity'];
|
||||
$mappingClassesPaths = [$environment->getBaseDirectory() . '/src/Entity'];
|
||||
|
||||
$buildDoctrineMappingPathsEvent = new Event\BuildDoctrineMappingPaths(
|
||||
$mappingClassesPaths,
|
||||
$settings->getBaseDirectory()
|
||||
$environment->getBaseDirectory()
|
||||
);
|
||||
$dispatcher->dispatch($buildDoctrineMappingPathsEvent);
|
||||
|
||||
|
@ -140,8 +140,8 @@ return [
|
|||
Doctrine\ORM\EntityManagerInterface::class => DI\Get(App\Doctrine\DecoratedEntityManager::class),
|
||||
|
||||
// Redis cache
|
||||
Redis::class => function (Settings $settings) {
|
||||
$redis_host = $settings->isDocker() ? 'redis' : 'localhost';
|
||||
Redis::class => function (Environment $environment) {
|
||||
$redis_host = $environment->isDocker() ? 'redis' : 'localhost';
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->connect($redis_host, 6379, 15);
|
||||
|
@ -150,7 +150,7 @@ return [
|
|||
return $redis;
|
||||
},
|
||||
|
||||
Psr\Cache\CacheItemPoolInterface::class => function (Settings $settings, ContainerInterface $di) {
|
||||
Psr\Cache\CacheItemPoolInterface::class => function (Environment $settings, ContainerInterface $di) {
|
||||
return !$settings->isTesting()
|
||||
? new Cache\Adapter\Redis\RedisCachePool($di->get(Redis::class))
|
||||
: new Cache\Adapter\PHPArray\ArrayCachePool;
|
||||
|
@ -159,7 +159,7 @@ return [
|
|||
|
||||
// Doctrine cache
|
||||
Doctrine\Common\Cache\Cache::class => function (
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Psr\Cache\CacheItemPoolInterface $cachePool
|
||||
) {
|
||||
if ($settings->isCli()) {
|
||||
|
@ -173,7 +173,7 @@ return [
|
|||
|
||||
// Session save handler middleware
|
||||
Mezzio\Session\SessionPersistenceInterface::class => function (
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Psr\Cache\CacheItemPoolInterface $cachePool
|
||||
) {
|
||||
if ($settings->isCli()) {
|
||||
|
@ -220,8 +220,8 @@ return [
|
|||
},
|
||||
|
||||
// Monolog Logger
|
||||
Monolog\Logger::class => function (Settings $settings) {
|
||||
$logger = new Monolog\Logger($settings[Settings::APP_NAME] ?? 'app');
|
||||
Monolog\Logger::class => function (Environment $environment) {
|
||||
$logger = new Monolog\Logger($environment[Environment::APP_NAME] ?? 'app');
|
||||
|
||||
$loggingLevel = null;
|
||||
if (!empty($_ENV['LOG_LEVEL'])) {
|
||||
|
@ -242,15 +242,15 @@ return [
|
|||
}
|
||||
}
|
||||
|
||||
$loggingLevel ??= $settings->isProduction() ? Psr\Log\LogLevel::NOTICE : Psr\Log\LogLevel::DEBUG;
|
||||
$loggingLevel ??= $environment->isProduction() ? Psr\Log\LogLevel::NOTICE : Psr\Log\LogLevel::DEBUG;
|
||||
|
||||
if ($settings->isDocker() || $settings->isCli()) {
|
||||
if ($environment->isDocker() || $environment->isCli()) {
|
||||
$log_stderr = new Monolog\Handler\StreamHandler('php://stderr', $loggingLevel, true);
|
||||
$logger->pushHandler($log_stderr);
|
||||
}
|
||||
|
||||
$log_file = new Monolog\Handler\StreamHandler(
|
||||
$settings[Settings::TEMP_DIR] . '/app.log',
|
||||
$environment[Environment::TEMP_DIR] . '/app.log',
|
||||
$loggingLevel,
|
||||
true
|
||||
);
|
||||
|
@ -263,7 +263,7 @@ return [
|
|||
// Doctrine annotations reader
|
||||
Doctrine\Common\Annotations\Reader::class => function (
|
||||
Doctrine\Common\Cache\Cache $doctrine_cache,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
return new Doctrine\Common\Annotations\CachedReader(
|
||||
new Doctrine\Common\Annotations\AnnotationReader,
|
||||
|
@ -351,7 +351,7 @@ return [
|
|||
},
|
||||
|
||||
// Supervisor manager
|
||||
Supervisor\Supervisor::class => function (Settings $settings) {
|
||||
Supervisor\Supervisor::class => function (Environment $settings) {
|
||||
$client = new fXmlRpc\Client(
|
||||
'http://' . ($settings->isDocker() ? 'stations' : '127.0.0.1') . ':9001/RPC2',
|
||||
new fXmlRpc\Transport\PsrTransport(
|
||||
|
@ -385,17 +385,17 @@ return [
|
|||
App\Media\MetadataManagerInterface::class => DI\get(App\Media\GetId3\GetId3MetadataManager::class),
|
||||
|
||||
// Asset Management
|
||||
App\Assets::class => function (App\Config $config, Settings $settings) {
|
||||
App\Assets::class => function (App\Config $config, Environment $environment) {
|
||||
$libraries = $config->get('assets');
|
||||
|
||||
$versioned_files = [];
|
||||
$assets_file = $settings[Settings::BASE_DIR] . '/web/static/assets.json';
|
||||
$assets_file = $environment->getBaseDirectory() . '/web/static/assets.json';
|
||||
if (file_exists($assets_file)) {
|
||||
$versioned_files = json_decode(file_get_contents($assets_file), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
$vueComponents = [];
|
||||
$assets_file = $settings[Settings::BASE_DIR] . '/web/static/webpack.json';
|
||||
$assets_file = $environment->getBaseDirectory() . '/web/static/webpack.json';
|
||||
if (file_exists($assets_file)) {
|
||||
$vueComponents = json_decode(file_get_contents($assets_file), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
|
|
@ -18,27 +18,26 @@ use Slim\Interfaces\RouteResolverInterface;
|
|||
|
||||
class AppFactory
|
||||
{
|
||||
public static function create($autoloader = null, $appSettings = [], $diDefinitions = []): App
|
||||
public static function create($autoloader = null, $appEnvironment = [], $diDefinitions = []): App
|
||||
{
|
||||
// Register Annotation autoloader
|
||||
if (null !== $autoloader) {
|
||||
AnnotationRegistry::registerLoader([$autoloader, 'loadClass']);
|
||||
}
|
||||
|
||||
$settings = new Settings(self::buildSettings($appSettings));
|
||||
Settings::setInstance($settings);
|
||||
$environment = new Environment(self::buildEnvironment($appEnvironment));
|
||||
Environment::setInstance($environment);
|
||||
|
||||
self::applyPhpSettings($settings);
|
||||
self::applyPhpSettings($environment);
|
||||
|
||||
// Helper constants for annotations.
|
||||
define('SAMPLE_TIMESTAMP', random_int(time() - 86400, time() + 86400));
|
||||
|
||||
// Override DI definitions for settings.
|
||||
$diDefinitions[Settings::class] = $settings;
|
||||
$diDefinitions['settings'] = DI\Get(Settings::class);
|
||||
$diDefinitions[Environment::class] = $environment;
|
||||
|
||||
if ($autoloader) {
|
||||
$plugins = new Plugins($settings[Settings::BASE_DIR] . '/plugins');
|
||||
$plugins = new Plugins($environment->getBaseDirectory() . '/plugins');
|
||||
|
||||
$diDefinitions[Plugins::class] = $plugins;
|
||||
$diDefinitions = $plugins->registerServices($diDefinitions);
|
||||
|
@ -46,7 +45,7 @@ class AppFactory
|
|||
$plugins = null;
|
||||
}
|
||||
|
||||
$di = self::buildContainer($settings, $diDefinitions);
|
||||
$di = self::buildContainer($environment, $diDefinitions);
|
||||
|
||||
Logger::setInstance($di->get(LoggerInterface::class));
|
||||
|
||||
|
@ -65,77 +64,77 @@ class AppFactory
|
|||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected static function buildSettings(array $settings): array
|
||||
protected static function buildEnvironment(array $environment): array
|
||||
{
|
||||
if (!isset($settings[Settings::BASE_DIR])) {
|
||||
if (!isset($environment[Environment::BASE_DIR])) {
|
||||
throw new Exception\BootstrapException('No base directory specified!');
|
||||
}
|
||||
|
||||
$settings[Settings::TEMP_DIR] = dirname($settings[Settings::BASE_DIR]) . '/www_tmp';
|
||||
$environment[Environment::TEMP_DIR] = dirname($environment[Environment::BASE_DIR]) . '/www_tmp';
|
||||
|
||||
$settings[Settings::IS_DOCKER] = file_exists(dirname($settings[Settings::BASE_DIR]) . '/.docker');
|
||||
$settings[Settings::DOCKER_REVISION] = getenv('AZURACAST_DC_REVISION') ?? 1;
|
||||
$environment[Environment::IS_DOCKER] = file_exists(dirname($environment[Environment::BASE_DIR]) . '/.docker');
|
||||
$environment[Environment::DOCKER_REVISION] = getenv('AZURACAST_DC_REVISION') ?? 1;
|
||||
|
||||
$settings[Settings::CONFIG_DIR] = $settings[Settings::BASE_DIR] . '/config';
|
||||
$settings[Settings::VIEWS_DIR] = $settings[Settings::BASE_DIR] . '/templates';
|
||||
$environment[Environment::CONFIG_DIR] = $environment[Environment::BASE_DIR] . '/config';
|
||||
$environment[Environment::VIEWS_DIR] = $environment[Environment::BASE_DIR] . '/templates';
|
||||
|
||||
if (!isset($settings[Settings::BASE_DIR])) {
|
||||
if (!isset($environment[Environment::BASE_DIR])) {
|
||||
throw new Exception\BootstrapException('No base directory specified!');
|
||||
}
|
||||
|
||||
if (!isset($settings[Settings::TEMP_DIR])) {
|
||||
$settings[Settings::TEMP_DIR] = dirname($settings[Settings::BASE_DIR]) . '/www_tmp';
|
||||
if (!isset($environment[Environment::TEMP_DIR])) {
|
||||
$environment[Environment::TEMP_DIR] = dirname($environment[Environment::BASE_DIR]) . '/www_tmp';
|
||||
}
|
||||
|
||||
if (!isset($settings[Settings::CONFIG_DIR])) {
|
||||
$settings[Settings::CONFIG_DIR] = $settings[Settings::BASE_DIR] . '/config';
|
||||
if (!isset($environment[Environment::CONFIG_DIR])) {
|
||||
$environment[Environment::CONFIG_DIR] = $environment[Environment::BASE_DIR] . '/config';
|
||||
}
|
||||
|
||||
if (!isset($settings[Settings::VIEWS_DIR])) {
|
||||
$settings[Settings::VIEWS_DIR] = $settings[Settings::BASE_DIR] . '/templates';
|
||||
if (!isset($environment[Environment::VIEWS_DIR])) {
|
||||
$environment[Environment::VIEWS_DIR] = $environment[Environment::BASE_DIR] . '/templates';
|
||||
}
|
||||
|
||||
if ($settings[Settings::IS_DOCKER]) {
|
||||
if ($environment[Environment::IS_DOCKER]) {
|
||||
$_ENV = getenv();
|
||||
} elseif (file_exists($settings[Settings::BASE_DIR] . '/env.ini')) {
|
||||
$_ENV = array_merge($_ENV, parse_ini_file($settings[Settings::BASE_DIR] . '/env.ini'));
|
||||
} elseif (file_exists($environment[Environment::BASE_DIR] . '/env.ini')) {
|
||||
$_ENV = array_merge($_ENV, parse_ini_file($environment[Environment::BASE_DIR] . '/env.ini'));
|
||||
}
|
||||
|
||||
if (!isset($settings[Settings::APP_ENV])) {
|
||||
$settings[Settings::APP_ENV] = $_ENV['APPLICATION_ENV'] ?? Settings::ENV_PRODUCTION;
|
||||
if (!isset($environment[Environment::APP_ENV])) {
|
||||
$environment[Environment::APP_ENV] = $_ENV['APPLICATION_ENV'] ?? Environment::ENV_PRODUCTION;
|
||||
}
|
||||
|
||||
if (isset($_ENV['BASE_URL'])) {
|
||||
$settings[Settings::BASE_URL] = $_ENV['BASE_URL'];
|
||||
$environment[Environment::BASE_URL] = $_ENV['BASE_URL'];
|
||||
}
|
||||
|
||||
if (isset($_ENV['ENABLE_ADVANCED_FEATURES'])) {
|
||||
$settings[Settings::ENABLE_ADVANCED_FEATURES] = $_ENV['ENABLE_ADVANCED_FEATURES'];
|
||||
$environment[Environment::ENABLE_ADVANCED_FEATURES] = $_ENV['ENABLE_ADVANCED_FEATURES'];
|
||||
}
|
||||
|
||||
if (file_exists($settings[Settings::CONFIG_DIR] . '/settings.php')) {
|
||||
$settingsFile = require($settings[Settings::CONFIG_DIR] . '/settings.php');
|
||||
if (file_exists($environment[Environment::CONFIG_DIR] . '/env.php')) {
|
||||
$envFile = require($environment[Environment::CONFIG_DIR] . '/env.php');
|
||||
|
||||
if (is_array($settingsFile)) {
|
||||
$settings = array_merge($settings, $settingsFile);
|
||||
if (is_array($envFile)) {
|
||||
$environment = array_merge($environment, $envFile);
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
return $environment;
|
||||
}
|
||||
|
||||
protected static function applyPhpSettings(Settings $settings): void
|
||||
protected static function applyPhpSettings(Environment $environment): void
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT);
|
||||
|
||||
ini_set('display_startup_errors', !$settings->isProduction() ? '1' : '0');
|
||||
ini_set('display_errors', !$settings->isProduction() ? '1' : '0');
|
||||
ini_set('display_startup_errors', !$environment->isProduction() ? '1' : '0');
|
||||
ini_set('display_errors', !$environment->isProduction() ? '1' : '0');
|
||||
ini_set('log_errors', '1');
|
||||
ini_set(
|
||||
'error_log',
|
||||
$settings[Settings::IS_DOCKER]
|
||||
$environment->isDocker()
|
||||
? '/dev/stderr'
|
||||
: $settings[Settings::TEMP_DIR] . '/php_errors.log'
|
||||
: $environment->getTempDirectory() . '/php_errors.log'
|
||||
);
|
||||
ini_set('session.use_only_cookies', '1');
|
||||
ini_set('session.cookie_httponly', '1');
|
||||
|
@ -147,25 +146,24 @@ class AppFactory
|
|||
session_cache_limiter('');
|
||||
}
|
||||
|
||||
protected static function buildContainer(Settings $settings, array $diDefinitions = []): DI\Container
|
||||
protected static function buildContainer(Environment $environment, array $diDefinitions = []): DI\Container
|
||||
{
|
||||
$containerBuilder = new DI\ContainerBuilder();
|
||||
$containerBuilder->useAnnotations(true);
|
||||
$containerBuilder->useAutowiring(true);
|
||||
|
||||
if ($settings->isProduction()) {
|
||||
$containerBuilder->enableCompilation($settings[Settings::TEMP_DIR]);
|
||||
if ($environment->isProduction()) {
|
||||
$containerBuilder->enableCompilation($environment->getTempDirectory());
|
||||
}
|
||||
|
||||
if (!isset($diDefinitions[Settings::class])) {
|
||||
$diDefinitions[Settings::class] = $settings;
|
||||
$diDefinitions['settings'] = DI\Get(Settings::class);
|
||||
if (!isset($diDefinitions[Environment::class])) {
|
||||
$diDefinitions[Environment::class] = $environment;
|
||||
}
|
||||
|
||||
$containerBuilder->addDefinitions($diDefinitions);
|
||||
|
||||
// Check for services.php file and include it if one exists.
|
||||
$config_dir = $settings[Settings::CONFIG_DIR];
|
||||
$config_dir = $environment->getConfigDirectory();
|
||||
if (file_exists($config_dir . '/services.php')) {
|
||||
$containerBuilder->addDefinitions($config_dir . '/services.php');
|
||||
}
|
||||
|
@ -213,8 +211,8 @@ class AppFactory
|
|||
$di = $app->getContainer();
|
||||
$routeCollector = $app->getRouteCollector();
|
||||
|
||||
/** @var Settings $settings */
|
||||
$settings = $di->get(Settings::class);
|
||||
/** @var Environment $environment */
|
||||
$environment = $di->get(Environment::class);
|
||||
|
||||
// Use the PHP-DI Bridge's action invocation helper.
|
||||
$resolvers = [
|
||||
|
@ -231,8 +229,8 @@ class AppFactory
|
|||
|
||||
$routeCollector->setDefaultInvocationStrategy($controllerInvoker);
|
||||
|
||||
if ($settings->isProduction()) {
|
||||
$routeCollector->setCacheFile($settings[Settings::TEMP_DIR] . '/app_routes.cache.php');
|
||||
if ($environment->isProduction()) {
|
||||
$routeCollector->setCacheFile($environment->getTempDirectory() . '/app_routes.cache.php');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ class Auth
|
|||
|
||||
protected UserRepository $userRepo;
|
||||
|
||||
protected Environment $environment;
|
||||
|
||||
/** @var User|bool|null */
|
||||
protected $user;
|
||||
|
||||
|
@ -28,10 +30,12 @@ class Auth
|
|||
|
||||
public function __construct(
|
||||
UserRepository $userRepo,
|
||||
SessionInterface $session
|
||||
SessionInterface $session,
|
||||
Environment $environment
|
||||
) {
|
||||
$this->userRepo = $userRepo;
|
||||
$this->session = $session;
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +114,7 @@ class Auth
|
|||
*/
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
if (Settings::getInstance()->isCli() && !Settings::getInstance()->isTesting()) {
|
||||
if ($this->environment->isCli() && !$this->environment->isTesting()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class Config
|
|||
{
|
||||
protected string $baseFolder;
|
||||
|
||||
public function __construct(Settings $settings)
|
||||
public function __construct(Environment $settings)
|
||||
{
|
||||
$this->baseFolder = $settings->getConfigDirectory();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use App\Version;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
|
@ -12,16 +12,16 @@ class GenerateApiDocsCommand extends CommandAbstract
|
|||
{
|
||||
public function __invoke(
|
||||
SymfonyStyle $io,
|
||||
Settings $settings
|
||||
Environment $environment
|
||||
): int {
|
||||
define('AZURACAST_API_URL', 'https://demo.azuracast.com/api');
|
||||
define('AZURACAST_API_NAME', 'AzuraCast Public Demo Server');
|
||||
define('AZURACAST_VERSION', Version::FALLBACK_VERSION);
|
||||
|
||||
$oa = scan([
|
||||
$settings[Settings::BASE_DIR] . '/util/openapi.php',
|
||||
$settings[Settings::BASE_DIR] . '/src/Entity',
|
||||
$settings[Settings::BASE_DIR] . '/src/Controller/Api',
|
||||
$environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$environment->getBaseDirectory() . '/src/Entity',
|
||||
$environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
], [
|
||||
'exclude' => [
|
||||
'bootstrap',
|
||||
|
@ -30,7 +30,7 @@ class GenerateApiDocsCommand extends CommandAbstract
|
|||
],
|
||||
]);
|
||||
|
||||
$yaml_path = $settings[Settings::BASE_DIR] . '/web/static/api/openapi.yml';
|
||||
$yaml_path = $environment->getBaseDirectory() . '/web/static/api/openapi.yml';
|
||||
$yaml = $oa->toYaml();
|
||||
|
||||
file_put_contents($yaml_path, $yaml);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Console\Command\Locale;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Gettext\Translations;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
@ -15,18 +15,18 @@ class GenerateCommand extends CommandAbstract
|
|||
{
|
||||
public function __invoke(
|
||||
SymfonyStyle $io,
|
||||
Settings $settings
|
||||
Environment $environment
|
||||
): int {
|
||||
$io->title('Generate Locales');
|
||||
|
||||
$dest_file = $settings[Settings::BASE_DIR] . '/resources/locale/default.pot';
|
||||
$dest_file = $environment->getBaseDirectory() . '/resources/locale/default.pot';
|
||||
$translations = new Translations();
|
||||
|
||||
// Find all PHP/PHTML files in the application's code.
|
||||
$translatable_folders = [
|
||||
$settings[Settings::BASE_DIR] . '/src',
|
||||
$settings[Settings::BASE_DIR] . '/config',
|
||||
$settings[Settings::VIEWS_DIR],
|
||||
$environment->getBaseDirectory() . '/src',
|
||||
$environment->getBaseDirectory() . '/config',
|
||||
$environment->getViewsDirectory(),
|
||||
];
|
||||
|
||||
foreach ($translatable_folders as $folder) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Console\Command\Locale;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Gettext\Translations;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
|
@ -11,12 +11,12 @@ class ImportCommand extends CommandAbstract
|
|||
{
|
||||
public function __invoke(
|
||||
SymfonyStyle $io,
|
||||
Settings $settings
|
||||
Environment $environment
|
||||
): int {
|
||||
$io->title('Import Locales');
|
||||
|
||||
$locales = $settings['locale']['supported'];
|
||||
$locale_base = $settings[Settings::BASE_DIR] . '/resources/locale';
|
||||
$locales = $environment['locale']['supported'];
|
||||
$locale_base = $environment->getBaseDirectory() . '/resources/locale';
|
||||
|
||||
foreach ($locales as $locale_key => $locale_name) {
|
||||
$locale_source = $locale_base . '/' . $locale_key . '/LC_MESSAGES/default.po';
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class MigrateConfigCommand extends CommandAbstract
|
||||
{
|
||||
public function __invoke(
|
||||
SymfonyStyle $io,
|
||||
Settings $settings
|
||||
Environment $environment
|
||||
): int {
|
||||
$env_path = $settings[Settings::BASE_DIR] . '/env.ini';
|
||||
$env_path = $environment->getBaseDirectory() . '/env.ini';
|
||||
$iniSettings = [];
|
||||
|
||||
if (file_exists($env_path)) {
|
||||
|
@ -23,19 +23,19 @@ class MigrateConfigCommand extends CommandAbstract
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($iniSettings['application_env']) && file_exists($settings[Settings::BASE_DIR] . '/app/.env')) {
|
||||
$iniSettings['application_env'] = @file_get_contents($settings[Settings::BASE_DIR] . '/app/.env');
|
||||
if (empty($iniSettings['application_env']) && file_exists($environment->getBaseDirectory() . '/app/.env')) {
|
||||
$iniSettings['application_env'] = @file_get_contents($environment->getBaseDirectory() . '/app/.env');
|
||||
}
|
||||
|
||||
if (empty($iniSettings['db_password'])) {
|
||||
$legacy_path = $settings[Settings::BASE_DIR] . '/app/env.ini';
|
||||
$legacy_path = $environment->getBaseDirectory() . '/app/env.ini';
|
||||
if (file_exists($legacy_path)) {
|
||||
$old_settings = parse_ini_file($legacy_path);
|
||||
$iniSettings = array_merge($iniSettings, $old_settings);
|
||||
}
|
||||
|
||||
if (file_exists($settings[Settings::BASE_DIR] . '/app/config/db.conf.php')) {
|
||||
$db_conf = include($settings[Settings::BASE_DIR] . '/app/config/db.conf.php');
|
||||
if (file_exists($environment->getBaseDirectory() . '/app/config/db.conf.php')) {
|
||||
$db_conf = include($environment->getBaseDirectory() . '/app/config/db.conf.php');
|
||||
$iniSettings['db_password'] = $db_conf['password'];
|
||||
|
||||
if ($db_conf['user'] === 'root') {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Console\Command;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -15,7 +15,7 @@ class SetupCommand extends CommandAbstract
|
|||
public function __invoke(
|
||||
SymfonyStyle $io,
|
||||
OutputInterface $output,
|
||||
Settings $settings,
|
||||
Environment $environment,
|
||||
ContainerInterface $di,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Entity\Repository\StationRepository $stationRepo,
|
||||
|
@ -27,14 +27,14 @@ class SetupCommand extends CommandAbstract
|
|||
$io->writeln(__('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...'));
|
||||
|
||||
$io->listing([
|
||||
__('Environment: %s', ucfirst($settings[Settings::APP_ENV])),
|
||||
__('Installation Method: %s', $settings->isDocker() ? 'Docker' : 'Ansible'),
|
||||
__('Environment: %s', ucfirst($environment[Environment::APP_ENV])),
|
||||
__('Installation Method: %s', $environment->isDocker() ? 'Docker' : 'Ansible'),
|
||||
]);
|
||||
|
||||
if ($update) {
|
||||
$io->note(__('Running in update mode.'));
|
||||
|
||||
if (!$settings->isDocker()) {
|
||||
if (!$environment->isDocker()) {
|
||||
$io->section(__('Migrating Legacy Configuration'));
|
||||
$this->runCommand($output, 'azuracast:config:migrate');
|
||||
$io->newLine();
|
||||
|
@ -59,7 +59,7 @@ class SetupCommand extends CommandAbstract
|
|||
$conn->ping();
|
||||
$this->runCommand($output, 'orm:generate-proxies');
|
||||
|
||||
if ($loadFixtures || (!$settings->isProduction() && !$update)) {
|
||||
if ($loadFixtures || (!$environment->isProduction() && !$update)) {
|
||||
$io->newLine();
|
||||
$io->section(__('Installing Data Fixtures'));
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Console\Command;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
||||
use Doctrine\Common\DataFixtures\Loader;
|
||||
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
||||
|
@ -18,12 +18,12 @@ class SetupFixturesCommand extends CommandAbstract
|
|||
SymfonyStyle $io,
|
||||
EntityManagerInterface $em,
|
||||
ContainerInterface $di,
|
||||
Settings $settings
|
||||
Environment $environment
|
||||
): int {
|
||||
$loader = new Loader();
|
||||
|
||||
// Dependency-inject the fixtures and load them.
|
||||
$fixturesDir = $settings[Settings::BASE_DIR] . '/src/Entity/Fixture';
|
||||
$fixturesDir = $environment[Environment::BASE_DIR] . '/src/Entity/Fixture';
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($fixturesDir),
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Acl;
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Quota;
|
||||
use App\Settings;
|
||||
use App\Sync\Runner;
|
||||
use Brick\Math\BigInteger;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -16,7 +16,8 @@ class IndexController
|
|||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
Runner $sync
|
||||
Runner $sync,
|
||||
Environment $environment
|
||||
): ResponseInterface {
|
||||
$view = $request->getView();
|
||||
$user = $request->getUser();
|
||||
|
@ -33,7 +34,7 @@ class IndexController
|
|||
]);
|
||||
}
|
||||
|
||||
$stationsBaseDir = Settings::getInstance()->getStationDirectory();
|
||||
$stationsBaseDir = $environment->getStationDirectory();
|
||||
|
||||
$spaceTotal = BigInteger::of(disk_total_space($stationsBaseDir));
|
||||
$spaceFree = BigInteger::of(disk_free_space($stationsBaseDir));
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Config;
|
||||
use App\Environment;
|
||||
use App\Form\Form;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Frontend\SHOUTcast;
|
||||
use App\Settings;
|
||||
use Exception;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
@ -24,8 +24,11 @@ class InstallShoutcastController
|
|||
$this->form_config = $config->get('forms/install_shoutcast');
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request, Response $response): ResponseInterface
|
||||
{
|
||||
public function __invoke(
|
||||
ServerRequest $request,
|
||||
Response $response,
|
||||
Environment $environment
|
||||
): ResponseInterface {
|
||||
$form_config = $this->form_config;
|
||||
|
||||
$version = SHOUTcast::getVersion();
|
||||
|
@ -41,7 +44,7 @@ class InstallShoutcastController
|
|||
|
||||
if ($request->isPost() && $form->isValid($request->getParsedBody())) {
|
||||
try {
|
||||
$sc_base_dir = Settings::getInstance()->getParentDirectory() . '/servers/shoutcast2';
|
||||
$sc_base_dir = $environment->getParentDirectory() . '/servers/shoutcast2';
|
||||
|
||||
$files = $request->getUploadedFiles();
|
||||
/** @var UploadedFileInterface $import_file */
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Controller\Admin;
|
|||
|
||||
use App\Controller\AbstractLogViewerController;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -15,9 +15,12 @@ class LogsController extends AbstractLogViewerController
|
|||
{
|
||||
protected EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
protected Environment $environment;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, Environment $environment)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request, Response $response): ResponseInterface
|
||||
|
@ -44,7 +47,7 @@ class LogsController extends AbstractLogViewerController
|
|||
*/
|
||||
protected function getGlobalLogs(): array
|
||||
{
|
||||
$tempDir = Settings::getInstance()->getTempDirectory();
|
||||
$tempDir = $this->environment->getTempDirectory();
|
||||
$logPaths = [];
|
||||
|
||||
$logPaths['azuracast_log'] = [
|
||||
|
@ -53,7 +56,7 @@ class LogsController extends AbstractLogViewerController
|
|||
'tail' => true,
|
||||
];
|
||||
|
||||
if (!Settings::getInstance()->isDocker()) {
|
||||
if (!$this->environment->isDocker()) {
|
||||
$logPaths['nginx_access'] = [
|
||||
'name' => __('Nginx Access Log'),
|
||||
'path' => $tempDir . '/access.log',
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\Environment;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use App\Version;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -12,13 +12,13 @@ use function OpenApi\scan;
|
|||
|
||||
class OpenApiController
|
||||
{
|
||||
protected Settings $settings;
|
||||
protected Environment $environment;
|
||||
|
||||
protected Version $version;
|
||||
|
||||
public function __construct(Settings $settings, Version $version)
|
||||
public function __construct(Environment $environment, Version $version)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ class OpenApiController
|
|||
define('AZURACAST_VERSION', $this->version->getVersion());
|
||||
|
||||
$oa = scan([
|
||||
$this->settings[Settings::BASE_DIR] . '/util/openapi.php',
|
||||
$this->settings[Settings::BASE_DIR] . '/src/Entity',
|
||||
$this->settings[Settings::BASE_DIR] . '/src/Controller/Api',
|
||||
$this->environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$this->environment->getBaseDirectory() . '/src/Entity',
|
||||
$this->environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
], [
|
||||
'exclude' => [
|
||||
'bootstrap',
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
namespace App\Controller\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception\NotLoggedInException;
|
||||
use App\Form\SettingsForm;
|
||||
use App\Form\StationForm;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Session\Flash;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -19,12 +19,12 @@ class SetupController
|
|||
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepository,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->settingsRepo = $settingsRepository;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Config;
|
||||
use App\Environment;
|
||||
use App\Form\Form;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Session\Flash;
|
||||
use App\Settings;
|
||||
use App\Sync\Task\RunAutomatedAssignmentTask;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
|
@ -19,14 +19,14 @@ class AutomationController
|
|||
|
||||
protected RunAutomatedAssignmentTask $sync_task;
|
||||
|
||||
protected Settings $app_settings;
|
||||
protected Environment $app_settings;
|
||||
|
||||
protected array $form_config;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
RunAutomatedAssignmentTask $sync_task,
|
||||
Settings $app_settings,
|
||||
Environment $app_settings,
|
||||
Config $config
|
||||
) {
|
||||
$this->em = $em;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Environment;
|
||||
use App\Exception\AdvancedFeatureException;
|
||||
use App\Exception\StationUnsupportedException;
|
||||
use App\Form\Form;
|
||||
|
@ -9,7 +10,6 @@ use App\Http\Response;
|
|||
use App\Http\ServerRequest;
|
||||
use App\Radio\Backend\Liquidsoap;
|
||||
use App\Session\Flash;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -19,7 +19,7 @@ class EditLiquidsoapConfigController
|
|||
ServerRequest $request,
|
||||
Response $response,
|
||||
EntityManagerInterface $em,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
$backend = $request->getStationBackend();
|
||||
|
|
|
@ -54,7 +54,7 @@ class Customization
|
|||
// Set up the PHP translator
|
||||
$translator = new Translator();
|
||||
|
||||
$locale_base = Settings::getInstance()->getBaseDirectory() . '/resources/locale/compiled';
|
||||
$locale_base = Environment::getInstance()->getBaseDirectory() . '/resources/locale/compiled';
|
||||
$locale_path = $locale_base . '/' . $this->locale . '.php';
|
||||
|
||||
if (file_exists($locale_path)) {
|
||||
|
@ -74,7 +74,7 @@ class Customization
|
|||
*/
|
||||
protected function initLocale(?ServerRequestInterface $request = null): string
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$settings = Environment::getInstance();
|
||||
|
||||
$supported_locales = $settings['locale']['supported'];
|
||||
$try_locales = [];
|
||||
|
@ -194,18 +194,18 @@ class Customization
|
|||
*/
|
||||
public function getPageTitle($title = null): string
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$settings = Environment::getInstance();
|
||||
|
||||
if (!$this->hideProductName()) {
|
||||
if ($title) {
|
||||
$title .= ' - ' . $settings[Settings::APP_NAME];
|
||||
$title .= ' - ' . $settings[Environment::APP_NAME];
|
||||
} else {
|
||||
$title = $settings[Settings::APP_NAME];
|
||||
$title = $settings[Environment::APP_NAME];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$settings->isProduction()) {
|
||||
$title = '(' . ucfirst($settings[Settings::APP_ENV]) . ') ' . $title;
|
||||
$title = '(' . ucfirst($settings[Environment::APP_ENV]) . ') ' . $title;
|
||||
}
|
||||
|
||||
return $title;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Doctrine;
|
||||
|
||||
use App\Environment;
|
||||
use App\Normalizer\DoctrineEntityNormalizer;
|
||||
use App\Settings;
|
||||
use Closure;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
@ -20,14 +20,14 @@ class Repository
|
|||
|
||||
protected Serializer $serializer;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->em = $em;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterface;
|
||||
use DateTimeInterface;
|
||||
|
@ -21,7 +21,7 @@ class SongHistoryRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
ListenerRepository $listenerRepository,
|
||||
StationQueueRepository $stationQueueRepository
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Entity\Repository;
|
|||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Entity\StationPlaylist;
|
||||
use App\Environment;
|
||||
use App\Exception\CannotProcessMediaException;
|
||||
use App\Exception\MediaProcessingException;
|
||||
use App\Flysystem\Filesystem;
|
||||
|
@ -13,7 +14,6 @@ use App\Media\AlbumArt;
|
|||
use App\Media\MetadataManagerInterface;
|
||||
use App\Media\MimeType;
|
||||
use App\Service\AudioWaveform;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
@ -40,7 +40,7 @@ class StationMediaRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
MetadataManagerInterface $metadataManager,
|
||||
CustomFieldRepository $customFieldRepo,
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Entity\Repository;
|
|||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Entity\StationPlaylist;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -19,7 +19,7 @@ class StationPlaylistMediaRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
StationQueueRepository $queueRepo
|
||||
) {
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Radio\Adapters;
|
||||
use App\Radio\Configuration;
|
||||
use App\Radio\Frontend\AbstractFrontend;
|
||||
use App\Settings;
|
||||
use App\Sync\Task\CheckMediaTask;
|
||||
use App\Utilities;
|
||||
use Closure;
|
||||
|
@ -39,7 +39,7 @@ class StationRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
SettingsRepository $settingsRepo,
|
||||
StorageLocationRepository $storageLocationRepo,
|
||||
LoggerInterface $logger,
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Radio\AutoDJ;
|
||||
use App\Settings;
|
||||
use App\Utilities;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterface;
|
||||
|
@ -21,7 +21,7 @@ class StationRequestRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
StationMediaRepository $mediaRepo
|
||||
) {
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Radio\AutoDJ\Scheduler;
|
||||
use App\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -19,7 +19,7 @@ class StationScheduleRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
Scheduler $scheduler
|
||||
) {
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Entity\Repository;
|
|||
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Flysystem\FilesystemManager;
|
||||
use App\Radio\Adapters;
|
||||
use App\Radio\AutoDJ\Scheduler;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
@ -23,7 +23,7 @@ class StationStreamerRepository extends Repository
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
LoggerInterface $logger,
|
||||
Scheduler $scheduler,
|
||||
StationStreamerBroadcastRepository $broadcastRepo,
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Annotations\AuditLog;
|
||||
use App\Environment;
|
||||
use App\File;
|
||||
use App\Normalizer\Annotation\DeepNormalize;
|
||||
use App\Radio\Adapters;
|
||||
use App\Settings;
|
||||
use App\Validator\Constraints as AppAssert;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
@ -632,7 +632,7 @@ class Station
|
|||
$newDir = $this->truncateString(trim($newDir));
|
||||
|
||||
if (empty($newDir)) {
|
||||
$stationsBaseDir = Settings::getInstance()->getStationDirectory();
|
||||
$stationsBaseDir = Environment::getInstance()->getStationDirectory();
|
||||
$newDir = $stationsBaseDir . '/' . $this->getShortName();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Annotations\AuditLog;
|
||||
use App\Environment;
|
||||
use App\Normalizer\Annotation\DeepNormalize;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -577,8 +578,8 @@ class StationPlaylist
|
|||
*/
|
||||
public function getBackendOptions(): array
|
||||
{
|
||||
$settings = \App\Settings::getInstance();
|
||||
if (!$settings->enableAdvancedFeatures()) {
|
||||
$environment = Environment::getInstance();
|
||||
if (!$environment->enableAdvancedFeatures()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App;
|
|||
use App\Traits\AvailableStaticallyTrait;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class Settings extends ArrayCollection
|
||||
class Environment extends ArrayCollection
|
||||
{
|
||||
use AvailableStaticallyTrait;
|
||||
|
|
@ -4,8 +4,8 @@ namespace App\Event;
|
|||
|
||||
use App\Acl;
|
||||
use App\Entity\User;
|
||||
use App\Environment;
|
||||
use App\Http\RouterInterface;
|
||||
use App\Settings;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
abstract class AbstractBuildMenu extends Event
|
||||
|
@ -16,7 +16,7 @@ abstract class AbstractBuildMenu extends Event
|
|||
|
||||
protected RouterInterface $router;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $environment;
|
||||
|
||||
protected array $menu = [];
|
||||
|
||||
|
@ -25,7 +25,7 @@ abstract class AbstractBuildMenu extends Event
|
|||
$this->acl = $acl;
|
||||
$this->user = $user;
|
||||
$this->router = $router;
|
||||
$this->settings = Settings::getInstance();
|
||||
$this->environment = Environment::getInstance();
|
||||
}
|
||||
|
||||
public function getAcl(): Acl
|
||||
|
@ -38,9 +38,9 @@ abstract class AbstractBuildMenu extends Event
|
|||
return $this->router;
|
||||
}
|
||||
|
||||
public function getSettings(): Settings
|
||||
public function getEnvironment(): Environment
|
||||
{
|
||||
return $this->settings;
|
||||
return $this->environment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Form;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
abstract class AbstractSettingsForm extends Form
|
||||
|
@ -13,12 +13,12 @@ abstract class AbstractSettingsForm extends Form
|
|||
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
array $formConfig
|
||||
) {
|
||||
parent::__construct($formConfig);
|
||||
|
@ -38,7 +38,7 @@ abstract class AbstractSettingsForm extends Form
|
|||
return $this->settingsRepo;
|
||||
}
|
||||
|
||||
public function getSettings(): Settings
|
||||
public function getSettings(): Environment
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class BackupSettingsForm extends AbstractSettingsForm
|
||||
|
@ -13,7 +13,7 @@ class BackupSettingsForm extends AbstractSettingsForm
|
|||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Config $config
|
||||
) {
|
||||
$formConfig = $config->get('forms/backup', [
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class BrandingSettingsForm extends AbstractSettingsForm
|
||||
|
@ -12,7 +12,7 @@ class BrandingSettingsForm extends AbstractSettingsForm
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Config $config
|
||||
) {
|
||||
$formConfig = $config->get('forms/branding', [
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Form;
|
||||
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Normalizer\DoctrineEntityNormalizer;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use InvalidArgumentException;
|
||||
|
@ -122,7 +122,7 @@ class EntityForm extends Form
|
|||
$this->em->flush();
|
||||
|
||||
// Intentionally refresh the station entity in case it didn't refresh elsewhere.
|
||||
if ($this->station instanceof Station && Settings::getInstance()->isTesting()) {
|
||||
if ($this->station instanceof Station && Environment::getInstance()->isTesting()) {
|
||||
$this->em->refresh($this->station);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use App\Sync\Task\UpdateGeoLiteTask;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
|
@ -15,7 +15,7 @@ class GeoLiteSettingsForm extends AbstractSettingsForm
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Config $config,
|
||||
UpdateGeoLiteTask $syncTask
|
||||
) {
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use App\Version;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
|
@ -14,7 +14,7 @@ class SettingsForm extends AbstractSettingsForm
|
|||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Version $version,
|
||||
Config $config
|
||||
) {
|
||||
|
|
|
@ -5,10 +5,10 @@ namespace App\Form;
|
|||
use App\Acl;
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Flysystem\FilesystemManager;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Configuration;
|
||||
use App\Settings;
|
||||
use App\Sync\Task\CheckMediaTask;
|
||||
use DeepCopy;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -35,7 +35,7 @@ class StationCloneForm extends StationForm
|
|||
Configuration $configuration,
|
||||
CheckMediaTask $media_sync,
|
||||
Config $config,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
FilesystemManager $filesystem
|
||||
) {
|
||||
parent::__construct(
|
||||
|
@ -197,7 +197,7 @@ class StationCloneForm extends StationForm
|
|||
}
|
||||
|
||||
// Set new radio base directory
|
||||
$station_base_dir = Settings::getInstance()->getStationDirectory();
|
||||
$station_base_dir = Environment::getInstance()->getStationDirectory();
|
||||
$new_record->setRadioBaseDir($station_base_dir . '/' . $new_record->getShortName());
|
||||
|
||||
$new_record->ensureDirectoriesExist();
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace App\Form;
|
|||
use App\Acl;
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Radio\Frontend\SHOUTcast;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
|
@ -21,7 +21,7 @@ class StationForm extends EntityForm
|
|||
|
||||
protected Acl $acl;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
|
@ -31,7 +31,7 @@ class StationForm extends EntityForm
|
|||
Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
||||
Acl $acl,
|
||||
Config $config,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
$this->acl = $acl;
|
||||
$this->entityClass = Entity\Station::class;
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\Router;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
@ -22,7 +22,7 @@ class StationWebhookForm extends EntityForm
|
|||
EntityManagerInterface $em,
|
||||
Serializer $serializer,
|
||||
ValidatorInterface $validator,
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
Config $config,
|
||||
Router $router
|
||||
) {
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Form;
|
|||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use AzuraForms\Field\AbstractField;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
@ -18,7 +18,7 @@ class UserProfileForm extends EntityForm
|
|||
Serializer $serializer,
|
||||
ValidatorInterface $validator,
|
||||
Config $config,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
$form_config = $config->get('forms/profile', [
|
||||
'settings' => $settings,
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Http;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Exception\NotLoggedInException;
|
||||
use App\Exception\PermissionDeniedException;
|
||||
use App\Session\Flash;
|
||||
use App\Settings;
|
||||
use App\ViewFactory;
|
||||
use Gettext\Translator;
|
||||
use Mezzio\Session\SessionInterface;
|
||||
|
@ -33,14 +33,14 @@ class ErrorHandler extends \Slim\Handlers\ErrorHandler
|
|||
|
||||
protected ViewFactory $viewFactory;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(
|
||||
App $app,
|
||||
Logger $logger,
|
||||
Router $router,
|
||||
ViewFactory $viewFactory,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
parent::__construct($app->getCallableResolver(), $app->getResponseFactory(), $logger);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Http;
|
||||
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Psr7\UriResolver;
|
||||
use InvalidArgumentException;
|
||||
|
@ -17,14 +17,14 @@ class Router implements RouterInterface
|
|||
{
|
||||
protected RouteParserInterface $routeParser;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
protected ?ServerRequestInterface $currentRequest = null;
|
||||
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
public function __construct(
|
||||
Settings $settings,
|
||||
Environment $settings,
|
||||
RouteParserInterface $routeParser,
|
||||
Entity\Repository\SettingsRepository $settingsRepo
|
||||
) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Middleware;
|
|||
use App\Auth;
|
||||
use App\Customization;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -20,18 +21,26 @@ class GetCurrentUser implements MiddlewareInterface
|
|||
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
protected Environment $environment;
|
||||
|
||||
public function __construct(
|
||||
Entity\Repository\UserRepository $userRepo,
|
||||
Entity\Repository\SettingsRepository $settingsRepo
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Environment $environment
|
||||
) {
|
||||
$this->userRepo = $userRepo;
|
||||
$this->settingsRepo = $settingsRepo;
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
// Initialize the Auth for this request.
|
||||
$auth = new Auth($this->userRepo, $request->getAttribute(ServerRequest::ATTR_SESSION));
|
||||
$auth = new Auth(
|
||||
$this->userRepo,
|
||||
$request->getAttribute(ServerRequest::ATTR_SESSION),
|
||||
$this->environment
|
||||
);
|
||||
$user = ($auth->isLoggedIn()) ? $auth->getLoggedInUser() : null;
|
||||
|
||||
$request = $request
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Middleware;
|
||||
|
||||
use App\Environment;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Session\Csrf;
|
||||
use App\Session\Flash;
|
||||
use App\Settings;
|
||||
use Mezzio\Session\LazySession;
|
||||
use Mezzio\Session\SessionPersistenceInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -20,11 +20,11 @@ class InjectSession implements MiddlewareInterface
|
|||
{
|
||||
protected SessionPersistenceInterface $sessionPersistence;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(
|
||||
SessionPersistenceInterface $sessionPersistence,
|
||||
Settings $settings
|
||||
Environment $settings
|
||||
) {
|
||||
$this->sessionPersistence = $sessionPersistence;
|
||||
$this->settings = $settings;
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Middleware;
|
||||
|
||||
use App\Doctrine\DecoratedEntityManager;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
@ -15,9 +15,9 @@ class ReopenEntityManagerMiddleware implements MiddlewareInterface
|
|||
{
|
||||
protected DecoratedEntityManager $em;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(DecoratedEntityManager $em, Settings $settings)
|
||||
public function __construct(DecoratedEntityManager $em, Environment $settings)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->settings = $settings;
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
namespace App\Notification\Check;
|
||||
|
||||
use App\Acl;
|
||||
use App\Environment;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Notification\Notification;
|
||||
use App\Settings;
|
||||
|
||||
class ComposeVersionCheck
|
||||
{
|
||||
protected Settings $appSettings;
|
||||
protected Environment $appSettings;
|
||||
|
||||
public function __construct(Settings $appSettings)
|
||||
public function __construct(Environment $appSettings)
|
||||
{
|
||||
$this->appSettings = $appSettings;
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@ namespace App\Notification\Check;
|
|||
|
||||
use App\Acl;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\GetNotifications;
|
||||
use App\Notification\Notification;
|
||||
use App\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
class RecentBackupCheck
|
||||
{
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
protected Settings $appSettings;
|
||||
protected Environment $appSettings;
|
||||
|
||||
public function __construct(Entity\Repository\SettingsRepository $settingsRepo, Settings $appSettings)
|
||||
public function __construct(Entity\Repository\SettingsRepository $settingsRepo, Environment $appSettings)
|
||||
{
|
||||
$this->settingsRepo = $settingsRepo;
|
||||
$this->appSettings = $appSettings;
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
namespace App\Radio;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\EventDispatcher;
|
||||
use App\Exception\Supervisor\AlreadyRunningException;
|
||||
use App\Exception\Supervisor\BadNameException;
|
||||
use App\Exception\Supervisor\NotRunningException;
|
||||
use App\Exception\SupervisorException;
|
||||
use App\Logger;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Supervisor\Exception\Fault;
|
||||
use Supervisor\Exception\SupervisorException as SupervisorLibException;
|
||||
|
@ -85,7 +85,7 @@ abstract class AbstractAdapter
|
|||
*/
|
||||
public function hasCommand(Entity\Station $station): bool
|
||||
{
|
||||
if (Settings::getInstance()->isTesting() || !$station->isEnabled()) {
|
||||
if (Environment::getInstance()->isTesting() || !$station->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Radio\Backend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\Radio\WriteLiquidsoapConfiguration;
|
||||
use App\EventDispatcher;
|
||||
use App\Exception;
|
||||
use App\Radio\Backend\Liquidsoap\ConfigWriter;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Supervisor\Supervisor;
|
||||
|
@ -176,7 +176,7 @@ class Liquidsoap extends AbstractBackend
|
|||
*/
|
||||
public function command(Entity\Station $station, $command_str): array
|
||||
{
|
||||
$hostname = (Settings::getInstance()->isDocker() ? 'stations' : 'localhost');
|
||||
$hostname = (Environment::getInstance()->isDocker() ? 'stations' : 'localhost');
|
||||
$fp = stream_socket_client(
|
||||
'tcp://' . $hostname . ':' . $this->getTelnetPort($station),
|
||||
$errno,
|
||||
|
@ -219,9 +219,9 @@ class Liquidsoap extends AbstractBackend
|
|||
public static function getBinary()
|
||||
{
|
||||
// Docker revisions 3 and later use the `radio` container.
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
if ($settings->isDocker() && $settings[Settings::DOCKER_REVISION] < 3) {
|
||||
if ($environment->isDocker() && $environment[Environment::DOCKER_REVISION] < 3) {
|
||||
return '/var/azuracast/.opam/system/bin/liquidsoap';
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Radio\Backend\Liquidsoap;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\Radio\WriteLiquidsoapConfiguration;
|
||||
use App\Exception;
|
||||
use App\Flysystem\FilesystemManager;
|
||||
|
@ -10,7 +11,6 @@ use App\Logger;
|
|||
use App\Message;
|
||||
use App\Radio\Adapters;
|
||||
use App\Radio\Backend\Liquidsoap;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
|
@ -32,14 +32,18 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
protected FilesystemManager $filesystem;
|
||||
|
||||
protected Environment $environment;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
Liquidsoap $liquidsoap,
|
||||
FilesystemManager $filesystem
|
||||
FilesystemManager $filesystem,
|
||||
Environment $environment
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->liquidsoap = $liquidsoap;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,14 +90,12 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$appSettings = Settings::getInstance();
|
||||
if (!$appSettings->enableAdvancedFeatures()) {
|
||||
if (!$this->environment->enableAdvancedFeatures()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$station = $event->getStation();
|
||||
$settings = $station->getBackendConfig();
|
||||
|
||||
if (!empty($settings[$sectionName])) {
|
||||
$event->appendLines([
|
||||
'# Custom Configuration (Specified in Station Profile)',
|
||||
|
@ -135,7 +137,7 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
'set("log.stdout", true)',
|
||||
'set("log.file", false)',
|
||||
'set("server.telnet",true)',
|
||||
'set("server.telnet.bind_addr","' . (Settings::getInstance()->isDocker() ? '0.0.0.0' : '127.0.0.1') . '")',
|
||||
'set("server.telnet.bind_addr","' . ($this->environment->isDocker() ? '0.0.0.0' : '127.0.0.1') . '")',
|
||||
'set("server.telnet.port", ' . $this->liquidsoap->getTelnetPort($station) . ')',
|
||||
'set("harbor.bind_addrs",["0.0.0.0"])',
|
||||
'',
|
||||
|
@ -649,14 +651,12 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
*/
|
||||
protected function getApiUrlCommand(Entity\Station $station, $endpoint, $params = []): string
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
|
||||
// Docker cURL-based API URL call with API authentication.
|
||||
if ($settings->isDocker()) {
|
||||
if ($this->environment->isDocker()) {
|
||||
$params = (array)$params;
|
||||
$params['api_auth'] = '!azuracast_api_auth';
|
||||
|
||||
$service_uri = ($settings[Settings::DOCKER_REVISION] >= 5) ? 'web' : 'nginx';
|
||||
$service_uri = ($this->environment[Environment::DOCKER_REVISION] >= 5) ? 'web' : 'nginx';
|
||||
$api_url = 'http://' . $service_uri . '/api/internal/' . $station->getId() . '/' . $endpoint;
|
||||
$command = 'curl -s --request POST --url ' . $api_url;
|
||||
foreach ($params as $paramKey => $paramVal) {
|
||||
|
@ -665,7 +665,7 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
}
|
||||
} else {
|
||||
// Ansible shell-script call.
|
||||
$shell_path = '/usr/bin/php ' . $settings->getBaseDirectory() . '/bin/console';
|
||||
$shell_path = '/usr/bin/php ' . $this->environment->getBaseDirectory() . '/bin/console';
|
||||
|
||||
$shell_args = [];
|
||||
$shell_args[] = 'azuracast:internal:' . $endpoint;
|
||||
|
@ -881,9 +881,9 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
}
|
||||
|
||||
// Write fallback to safety file to ensure infallible source for the broadcast outputs.
|
||||
$error_file = Settings::getInstance()->isDocker()
|
||||
$error_file = $this->environment->isDocker()
|
||||
? '/usr/local/share/icecast/web/error.mp3'
|
||||
: Settings::getInstance()->getBaseDirectory() . '/resources/error.mp3';
|
||||
: $this->environment->getBaseDirectory() . '/resources/error.mp3';
|
||||
|
||||
$event->appendLines([
|
||||
sprintf(
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
namespace App\Radio;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
class CertificateLocator
|
||||
{
|
||||
public static function findCertificate(): Certificate
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
if (!empty($_ENV['VIRTUAL_HOST']) && $settings->isDockerRevisionNewerThan(10)) {
|
||||
if (!empty($_ENV['VIRTUAL_HOST']) && $environment->isDockerRevisionNewerThan(10)) {
|
||||
$vhost = $_ENV['VIRTUAL_HOST'];
|
||||
|
||||
// Check environment variable for a virtual host.
|
||||
|
@ -38,9 +38,9 @@ class CertificateLocator
|
|||
|
||||
public static function getDefaultCertificates(): Certificate
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
if ($settings->isDocker()) {
|
||||
if ($environment->isDocker()) {
|
||||
return new Certificate('/etc/nginx/ssl.key', '/etc/nginx/ssl.crt');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Radio;
|
||||
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use fXmlRpc\Exception\FaultException;
|
||||
use Monolog\Logger;
|
||||
|
@ -44,7 +44,7 @@ class Configuration
|
|||
*/
|
||||
public function writeConfiguration(Station $station, $regen_auth_key = false, $force_restart = false): void
|
||||
{
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ class Configuration
|
|||
*/
|
||||
public function removeConfiguration(Station $station): void
|
||||
{
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\EventDispatcher;
|
||||
use App\Http\Router;
|
||||
use App\Radio\AbstractAdapter;
|
||||
use App\Settings;
|
||||
use App\Xml\Reader;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -153,7 +153,7 @@ abstract class AbstractFrontend extends AbstractAdapter
|
|||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|| (!Settings::getInstance()->isProduction() && !Settings::getInstance()->isDocker())
|
||||
|| (!Environment::getInstance()->isProduction() && !Environment::getInstance()->isDocker())
|
||||
|| 'https' === $base_url->getScheme()
|
||||
) {
|
||||
// Web proxy support.
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Logger;
|
||||
use App\Radio\CertificateLocator;
|
||||
use App\Settings;
|
||||
use App\Utilities;
|
||||
use App\Xml\Reader;
|
||||
use App\Xml\Writer;
|
||||
|
@ -27,7 +27,7 @@ class Icecast extends AbstractFrontend
|
|||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
|
||||
$baseUrl = 'http://' . (Settings::getInstance()->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
$baseUrl = 'http://' . (Environment::getInstance()->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
|
||||
$npAdapter = $this->adapterFactory->getAdapter(
|
||||
AdapterFactory::ADAPTER_ICECAST,
|
||||
|
@ -104,7 +104,7 @@ class Icecast extends AbstractFrontend
|
|||
protected function getDefaults(Entity\Station $station): array
|
||||
{
|
||||
$config_dir = $station->getRadioConfigDir();
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
$settingsBaseUrl = $this->settingsRepo->getSetting(Entity\Settings::BASE_URL, 'http://localhost');
|
||||
if (strpos($settingsBaseUrl, 'http') !== 0) {
|
||||
|
@ -158,12 +158,12 @@ class Icecast extends AbstractFrontend
|
|||
'ssl-allowed-ciphers' => 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS',
|
||||
// phpcs:enable
|
||||
'deny-ip' => $this->writeIpBansFile($station),
|
||||
'x-forwarded-for' => $settings->isDocker() ? '172.*.*.*' : '127.0.0.1',
|
||||
'x-forwarded-for' => $environment->isDocker() ? '172.*.*.*' : '127.0.0.1',
|
||||
],
|
||||
'logging' => [
|
||||
'accesslog' => 'icecast_access.log',
|
||||
'errorlog' => '/dev/stderr',
|
||||
'loglevel' => $settings->isProduction() ? self::LOGLEVEL_WARN : self::LOGLEVEL_INFO,
|
||||
'loglevel' => $environment->isProduction() ? self::LOGLEVEL_WARN : self::LOGLEVEL_INFO,
|
||||
'logsize' => 10000,
|
||||
],
|
||||
'security' => [
|
||||
|
@ -362,7 +362,7 @@ class Icecast extends AbstractFrontend
|
|||
$new_path = '/usr/local/bin/icecast';
|
||||
$legacy_path = '/usr/bin/icecast2';
|
||||
|
||||
if (Settings::getInstance()->isDocker() || file_exists($new_path)) {
|
||||
if (Environment::getInstance()->isDocker() || file_exists($new_path)) {
|
||||
return $new_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Radio\Frontend;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Logger;
|
||||
use App\Settings;
|
||||
use App\Utilities;
|
||||
use Exception;
|
||||
use NowPlaying\Adapter\AdapterFactory;
|
||||
|
@ -40,8 +40,8 @@ class SHOUTcast extends AbstractFrontend
|
|||
$new_path = '/var/azuracast/servers/shoutcast2/sc_serv';
|
||||
|
||||
// Docker versions before 3 included the SC binary across the board.
|
||||
$settings = Settings::getInstance();
|
||||
if ($settings->isDocker() && $settings[Settings::DOCKER_REVISION] < 3) {
|
||||
$environment = Environment::getInstance();
|
||||
if ($environment->isDocker() && $environment[Environment::DOCKER_REVISION] < 3) {
|
||||
return $new_path;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class SHOUTcast extends AbstractFrontend
|
|||
{
|
||||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
$baseUrl = 'http://' . (Settings::getInstance()->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
$baseUrl = 'http://' . (Environment::getInstance()->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
|
||||
$npAdapter = $this->adapterFactory->getAdapter(
|
||||
AdapterFactory::ADAPTER_SHOUTCAST2,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Radio\Remote;
|
||||
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use InvalidArgumentException;
|
||||
use NowPlaying\Result\Result;
|
||||
|
@ -71,7 +71,7 @@ class AzuraRelay extends AbstractRemote
|
|||
|
||||
if (
|
||||
$use_radio_proxy
|
||||
|| (!Settings::getInstance()->isProduction() && !Settings::getInstance()->isDocker())
|
||||
|| (!Environment::getInstance()->isProduction() && !Environment::getInstance()->isDocker())
|
||||
|| 'https' === $base_url->getScheme()
|
||||
) {
|
||||
// Web proxy support.
|
||||
|
|
|
@ -9,9 +9,9 @@ class RateLimit
|
|||
{
|
||||
protected Redis $redis;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(Redis $redis, Settings $settings)
|
||||
public function __construct(Redis $redis, Environment $settings)
|
||||
{
|
||||
$this->redis = $redis;
|
||||
$this->settings = $settings;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Service;
|
||||
|
||||
use App\Entity;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use App\Version;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -13,7 +13,7 @@ class AzuraCastCentral
|
|||
{
|
||||
protected const BASE_URL = 'https://central.azuracast.com';
|
||||
|
||||
protected Settings $appSettings;
|
||||
protected Environment $environment;
|
||||
|
||||
protected Client $httpClient;
|
||||
|
||||
|
@ -25,13 +25,13 @@ class AzuraCastCentral
|
|||
|
||||
public function __construct(
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
Settings $appSettings,
|
||||
Environment $environment,
|
||||
Version $version,
|
||||
Client $httpClient,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->settingsRepo = $settingsRepo;
|
||||
$this->appSettings = $appSettings;
|
||||
$this->environment = $environment;
|
||||
$this->version = $version;
|
||||
$this->httpClient = $httpClient;
|
||||
$this->logger = $logger;
|
||||
|
@ -48,8 +48,8 @@ class AzuraCastCentral
|
|||
|
||||
$request_body = [
|
||||
'id' => $app_uuid,
|
||||
'is_docker' => $this->appSettings->isDocker(),
|
||||
'environment' => $this->appSettings[Settings::APP_ENV],
|
||||
'is_docker' => $this->environment->isDocker(),
|
||||
'environment' => $this->environment[Environment::APP_ENV],
|
||||
'release_channel' => $this->version->getReleaseChannel(),
|
||||
];
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Service\IpGeolocator;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
class DbIp extends AbstractIpGeolocator
|
||||
{
|
||||
public static function getBaseDirectory(): string
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
return dirname($settings[Settings::BASE_DIR]) . '/dbip';
|
||||
$environment = Environment::getInstance();
|
||||
return dirname($environment[Environment::BASE_DIR]) . '/dbip';
|
||||
}
|
||||
|
||||
public static function getDatabasePath(): string
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App\Service\IpGeolocator;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
class GeoLite extends AbstractIpGeolocator
|
||||
{
|
||||
public static function getBaseDirectory(): string
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
return dirname($settings[Settings::BASE_DIR]) . '/geoip';
|
||||
$environment = Environment::getInstance();
|
||||
return dirname($environment[Environment::BASE_DIR]) . '/geoip';
|
||||
}
|
||||
|
||||
public static function getDatabasePath(): string
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
/**
|
||||
* Utility class for managing NChan, the nginx websocket/SSE/long-polling module.
|
||||
|
@ -14,14 +14,14 @@ class NChan
|
|||
*/
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
if ($settings->isTesting()) {
|
||||
if ($environment->isTesting()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($settings->isDocker()) {
|
||||
return $settings[Settings::DOCKER_REVISION] >= 5;
|
||||
if ($environment->isDocker()) {
|
||||
return $environment[Environment::DOCKER_REVISION] >= 5;
|
||||
}
|
||||
|
||||
// Check for support for Ansible installations.
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
namespace App\Service;
|
||||
|
||||
use App\Entity\Station;
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
class SftpGo
|
||||
{
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
$environment = Environment::getInstance();
|
||||
|
||||
return !$settings->isTesting() && $settings->isDockerRevisionNewerThan(7);
|
||||
return !$environment->isTesting() && $environment->isDockerRevisionNewerThan(7);
|
||||
}
|
||||
|
||||
public static function isSupportedForStation(Station $station): bool
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Session;
|
||||
|
||||
use App\Environment;
|
||||
use App\Exception;
|
||||
use App\Settings;
|
||||
use App\Traits\AvailableStaticallyTrait;
|
||||
use Mezzio\Session\SessionInterface;
|
||||
|
||||
|
@ -16,9 +16,9 @@ class Csrf
|
|||
|
||||
protected SessionInterface $session;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $settings;
|
||||
|
||||
public function __construct(SessionInterface $session, Settings $settings)
|
||||
public function __construct(SessionInterface $session, Environment $settings)
|
||||
{
|
||||
$this->session = $session;
|
||||
$this->settings = $settings;
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Sync;
|
|||
|
||||
use App\Entity;
|
||||
use App\Entity\Repository\SettingsRepository;
|
||||
use App\Environment;
|
||||
use App\Event\GetSyncTasks;
|
||||
use App\EventDispatcher;
|
||||
use App\LockFactory;
|
||||
use App\Settings;
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ class Runner
|
|||
|
||||
set_time_limit($syncInfo['timeout']);
|
||||
|
||||
if (Settings::getInstance()->isCli()) {
|
||||
if (Environment::getInstance()->isCli()) {
|
||||
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Sync\Task;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Service\AzuraCastCentral;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -37,7 +37,7 @@ class CheckUpdatesTask extends AbstractTask
|
|||
}
|
||||
}
|
||||
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
$this->logger->info('Update checks are currently disabled for this AzuraCast instance.');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Sync\Task;
|
|||
|
||||
use App\Entity;
|
||||
use App\Entity\Station;
|
||||
use App\Environment;
|
||||
use App\Event\Radio\GenerateRawNowPlaying;
|
||||
use App\Event\SendWebhooks;
|
||||
use App\EventDispatcher;
|
||||
|
@ -12,7 +13,6 @@ use App\LockFactory;
|
|||
use App\Message;
|
||||
use App\Radio\Adapters;
|
||||
use App\Radio\AutoDJ;
|
||||
use App\Settings;
|
||||
use DeepCopy\DeepCopy;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
|
@ -87,7 +87,7 @@ class NowPlayingTask extends AbstractTask implements EventSubscriberInterface
|
|||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Sync\Task;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Radio\Adapters;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use studio24\Rotate;
|
||||
|
@ -13,7 +13,7 @@ use Symfony\Component\Finder\Finder;
|
|||
|
||||
class RotateLogsTask extends AbstractTask
|
||||
{
|
||||
protected Settings $appSettings;
|
||||
protected Environment $appSettings;
|
||||
|
||||
protected Adapters $adapters;
|
||||
|
||||
|
@ -25,7 +25,7 @@ class RotateLogsTask extends AbstractTask
|
|||
EntityManagerInterface $em,
|
||||
Entity\Repository\SettingsRepository $settingsRepo,
|
||||
LoggerInterface $logger,
|
||||
Settings $appSettings,
|
||||
Environment $appSettings,
|
||||
Adapters $adapters,
|
||||
Supervisor $supervisor,
|
||||
Entity\Repository\StorageLocationRepository $storageLocationRepo
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
use Codeception\Configuration;
|
||||
use Codeception\Lib\Framework;
|
||||
use Codeception\Lib\Interfaces\DoctrineProvider;
|
||||
|
@ -34,8 +34,8 @@ class Module extends Framework implements DoctrineProvider
|
|||
$autoloader = $GLOBALS['autoloader'];
|
||||
|
||||
$this->app = $container_class::create($autoloader, [
|
||||
Settings::BASE_DIR => Configuration::projectDir(),
|
||||
Settings::APP_ENV => Settings::ENV_TESTING,
|
||||
Environment::BASE_DIR => Configuration::projectDir(),
|
||||
Environment::APP_ENV => Environment::ENV_TESTING,
|
||||
]);
|
||||
|
||||
$this->container = $this->app->getContainer();
|
||||
|
|
|
@ -22,19 +22,18 @@ class Version
|
|||
|
||||
protected string $repoDir;
|
||||
|
||||
protected Settings $appSettings;
|
||||
protected Environment $environment;
|
||||
|
||||
public function __construct(CacheInterface $cache, Settings $appSettings)
|
||||
public function __construct(CacheInterface $cache, Environment $environment)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->appSettings = $appSettings;
|
||||
|
||||
$this->repoDir = $appSettings[Settings::BASE_DIR];
|
||||
$this->environment = $environment;
|
||||
$this->repoDir = $environment->getBaseDirectory();
|
||||
}
|
||||
|
||||
public function getReleaseChannel(): string
|
||||
{
|
||||
if ($this->appSettings->isDocker()) {
|
||||
if ($this->environment->isDocker()) {
|
||||
$channel = $_ENV['AZURACAST_VERSION'] ?? 'latest';
|
||||
|
||||
return ('stable' === $channel)
|
||||
|
@ -72,7 +71,7 @@ class Version
|
|||
|
||||
if (empty($details)) {
|
||||
$details = $this->getRawDetails();
|
||||
$ttl = $this->appSettings->isProduction() ? 86400 : 600;
|
||||
$ttl = $this->environment->isProduction() ? 86400 : 600;
|
||||
|
||||
$this->cache->set('app_version_details', $details, $ttl);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class ViewFactory
|
|||
{
|
||||
protected ContainerInterface $di;
|
||||
|
||||
protected Settings $settings;
|
||||
protected Environment $environment;
|
||||
|
||||
protected EventDispatcher $dispatcher;
|
||||
|
||||
|
@ -25,13 +25,13 @@ class ViewFactory
|
|||
|
||||
public function __construct(
|
||||
ContainerInterface $di,
|
||||
Settings $settings,
|
||||
Environment $environment,
|
||||
EventDispatcher $dispatcher,
|
||||
Version $version,
|
||||
Assets $assets
|
||||
) {
|
||||
$this->di = $di;
|
||||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->version = $version;
|
||||
$this->assets = $assets;
|
||||
|
@ -39,11 +39,11 @@ class ViewFactory
|
|||
|
||||
public function create(ServerRequestInterface $request): View
|
||||
{
|
||||
$view = new View($this->settings[Settings::VIEWS_DIR], 'phtml');
|
||||
$view = new View($this->environment->getViewsDirectory(), 'phtml');
|
||||
|
||||
// Add non-request-dependent content.
|
||||
$view->addData([
|
||||
'settings' => $this->settings,
|
||||
'environment' => $this->environment,
|
||||
'version' => $this->version,
|
||||
]);
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Webhook;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\SendWebhooks;
|
||||
use App\Exception;
|
||||
use App\Http\RouterInterface;
|
||||
use App\Message;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Logger;
|
||||
|
@ -49,7 +49,7 @@ class Dispatcher implements EventSubscriberInterface
|
|||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class Dispatcher implements EventSubscriberInterface
|
|||
*/
|
||||
public function dispatch(SendWebhooks $event): void
|
||||
{
|
||||
if (Settings::getInstance()->isTesting()) {
|
||||
if (Environment::getInstance()->isTesting()) {
|
||||
$this->logger->info('In testing mode; no webhooks dispatched.');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace App\Webhook;
|
||||
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use App\Event\SendWebhooks;
|
||||
use App\Service\NChan;
|
||||
use App\Settings;
|
||||
use GuzzleHttp\Client;
|
||||
use Monolog\Logger;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
@ -86,7 +86,7 @@ class LocalWebhookHandler
|
|||
// Write JSON file to disk so nginx can serve it without calling the PHP stack at all.
|
||||
$this->logger->debug('Writing static nowplaying text file...');
|
||||
|
||||
$static_np_dir = Settings::getInstance()->getTempDirectory() . '/nowplaying';
|
||||
$static_np_dir = Environment::getInstance()->getTempDirectory() . '/nowplaying';
|
||||
if (!is_dir($static_np_dir) && !mkdir($static_np_dir) && !is_dir($static_np_dir)) {
|
||||
throw new RuntimeException(sprintf('Directory "%s" was not created', $static_np_dir));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* @var array $backups
|
||||
* @var \App\Assets $assets
|
||||
* @var App\Assets $assets
|
||||
* @var App\Environment $environment
|
||||
*/
|
||||
|
||||
$this->layout('main', [
|
||||
|
@ -66,7 +67,7 @@ $assets
|
|||
<div class="card-body">
|
||||
<p class="card-text"><?=__('To restore a backup from your host computer, run:')?></p>
|
||||
|
||||
<?php if (\App\Settings::getInstance()->isDocker()): ?>
|
||||
<?php if ($environment->isDocker()): ?>
|
||||
<pre><code>./docker.sh restore path_to_backup.zip</code></pre>
|
||||
<?php else: ?>
|
||||
<pre><code>/var/azuracast/www/bin/console azuracast:restore path_to_backup.zip</code></pre>
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @var App\Environment $environment
|
||||
*/
|
||||
|
||||
$this->layout('main', [
|
||||
'title' => __('Log Viewer'),
|
||||
'manual' => true
|
||||
'manual' => true,
|
||||
]);
|
||||
?>
|
||||
|
||||
|
@ -9,18 +13,20 @@ $this->layout('main', [
|
|||
<div class="col-md-8">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header bg-primary-dark">
|
||||
<h2 class="card-title"><?=__('System Logs') ?></h2>
|
||||
<h2 class="card-title"><?=__('System Logs')?></h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if (\App\Settings::getInstance()->isDocker()): ?>
|
||||
<p><?=__('Because you are running Docker, some system logs can only be accessed from a shell session on the host computer. You can run <code>%s</code> to access container logs from the terminal.', 'docker-compose logs -f (nginx|web|stations|...)') ?></p>
|
||||
<?php if ($environment->isDocker()): ?>
|
||||
<p><?=__('Because you are running Docker, some system logs can only be accessed from a shell session on the host computer. You can run <code>%s</code> to access container logs from the terminal.',
|
||||
'docker-compose logs -f (nginx|web|stations|...)')?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach($global_logs as $log_key => $log_info): ?>
|
||||
<a class="list-group-item list-group-item-action log-item" href="<?=$router->fromHere('admin:logs:view', ['station_id' => 'global', 'log' => $log_key]) ?>">
|
||||
<span class="log-name"><?=$log_info['name'] ?></span><br>
|
||||
<small class="text-secondary"><?=$log_info['path'] ?></small>
|
||||
<?php foreach ($global_logs as $log_key => $log_info): ?>
|
||||
<a class="list-group-item list-group-item-action log-item" href="<?=$router->fromHere('admin:logs:view',
|
||||
['station_id' => 'global', 'log' => $log_key])?>">
|
||||
<span class="log-name"><?=$log_info['name']?></span><br>
|
||||
<small class="text-secondary"><?=$log_info['path']?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
@ -28,34 +34,35 @@ $this->layout('main', [
|
|||
|
||||
<div class="card">
|
||||
<div class="card-header bg-primary-dark">
|
||||
<h2 class="card-title"><?=__('Logs by Station') ?></h2>
|
||||
<h2 class="card-title"><?=__('Logs by Station')?></h2>
|
||||
</div>
|
||||
<div class="card-body pb-0">
|
||||
<ul class="nav nav-pills nav-pills-scrollable card-header-pills">
|
||||
<?php foreach($station_logs as $station_id => $station_row): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" role="tab" data-toggle="tab" aria-expanded="true" aria-controls="logs_station_<?=$station_id ?>" href="#logs_station_<?=$station_id ?>"><?=$this->e($station_row['name']) ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($station_logs as $station_id => $station_row): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" role="tab" data-toggle="tab" aria-expanded="true" aria-controls="logs_station_<?=$station_id?>" href="#logs_station_<?=$station_id?>"><?=$this->e($station_row['name'])?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<?php foreach($station_logs as $station_id => $station_row): ?>
|
||||
<div class="list-group list-group-flush tab-pane" id="logs_station_<?=$station_id ?>">
|
||||
<?php foreach($station_row['logs'] as $log_key => $log_info): ?>
|
||||
<a class="list-group-item list-group-item-action log-item" href="<?=$router->fromHere('admin:logs:view', ['station_id' => $station_id, 'log' => $log_key]) ?>">
|
||||
<span class="log-name"><?=$log_info['name'] ?></span><br>
|
||||
<small class="text-secondary"><?=$log_info['path'] ?></small>
|
||||
</a>
|
||||
<?php foreach ($station_logs as $station_id => $station_row): ?>
|
||||
<div class="list-group list-group-flush tab-pane" id="logs_station_<?=$station_id?>">
|
||||
<?php foreach ($station_row['logs'] as $log_key => $log_info): ?>
|
||||
<a class="list-group-item list-group-item-action log-item" href="<?=$router->fromHere('admin:logs:view',
|
||||
['station_id' => $station_id, 'log' => $log_key])?>">
|
||||
<span class="log-name"><?=$log_info['name']?></span><br>
|
||||
<small class="text-secondary"><?=$log_info['path']?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?=$this->fetch('partials/log_help_card') ?>
|
||||
<?=$this->fetch('partials/log_help_card')?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?=$this->fetch('partials/log_viewer') ?>
|
||||
<?=$this->fetch('partials/log_viewer')?>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* @var App\Assets $assets
|
||||
* @var App\Version $version
|
||||
* @var App\Http\ServerRequest $request
|
||||
* @var array $app_settings
|
||||
* @var App\Environment $environment
|
||||
*/
|
||||
|
||||
$page_class ??= '';
|
||||
|
@ -153,7 +153,7 @@ $user = $request->getUser();
|
|||
|
||||
<footer id="footer" <?php if (empty($sidebar)): ?>class="footer-alt"<?php endif; ?> role="contentinfo">
|
||||
<?=__('Powered by %s',
|
||||
'<a href="https://www.azuracast.com/" target="_blank">' . $settings['name'] . '</a> • ' . $version->getVersionText() . ' • ' . (\App\Settings::getInstance()->isDocker() ? 'Docker' : 'Ansible') . ' • PHP ' . \PHP_MAJOR_VERSION . '.' . \PHP_MINOR_VERSION)?>
|
||||
'<a href="https://www.azuracast.com/" target="_blank">' . $settings['name'] . '</a> • ' . $version->getVersionText() . ' • ' . ($environment->isDocker() ? 'Docker' : 'Ansible') . ' • PHP ' . \PHP_MAJOR_VERSION . '.' . \PHP_MINOR_VERSION)?>
|
||||
<br>
|
||||
<?=__('Like our software? <a href="%s" target="_blank">Donate to support AzuraCast!</a>',
|
||||
'https://www.azuracast.com/donate.html')?>
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
// Icons generated by:
|
||||
// http://www.favicon-generator.org/
|
||||
|
||||
/** @var \App\Settings $settings */
|
||||
$icon_base = '/static/icons/'.$settings[\App\Settings::APP_ENV];
|
||||
/** @var App\Environment $environment */
|
||||
$icon_base = '/static/icons/' . $environment[App\Environment::APP_ENV];
|
||||
?>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?=$icon_base ?>/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="<?=$icon_base ?>/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<?=$icon_base ?>/favicon-16x16.png">
|
||||
<link rel="manifest" href="<?=$icon_base ?>/site.webmanifest">
|
||||
<link rel="mask-icon" href="<?=$icon_base ?>/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="<?=$icon_base ?>/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<?=$icon_base?>/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="<?=$icon_base?>/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="<?=$icon_base?>/favicon-16x16.png">
|
||||
<link rel="manifest" href="<?=$icon_base?>/site.webmanifest">
|
||||
<link rel="mask-icon" href="<?=$icon_base?>/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="<?=$icon_base?>/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#2196F3">
|
||||
<meta name="msapplication-config" content="<?=$icon_base ?>/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="<?=$icon_base?>/browserconfig.xml">
|
||||
<meta name="theme-color" content="#2196F3">
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
<div class="card">
|
||||
<div class="card-header bg-primary-dark">
|
||||
<h2 class="card-title"><?=__('Need Help?') ?></h2>
|
||||
<h2 class="card-title"><?=__('Need Help?')?></h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?=__('You can find answers for many common questions in our <a href="%s" target="_blank">support documents</a>.', 'https://www.azuracast.com/help/') ?></p>
|
||||
<p><?=__('You can find answers for many common questions in our <a href="%s" target="_blank">support documents</a>.',
|
||||
'https://www.azuracast.com/help/')?></p>
|
||||
|
||||
<p><?=__('If you\'re experiencing a bug or error, you can submit a GitHub issue using the link below.') ?></p>
|
||||
<p><?=__('If you\'re experiencing a bug or error, you can submit a GitHub issue using the link below.')?></p>
|
||||
|
||||
<p><?=__('Your current installation type is <b>%s</b>. Be sure to include this when creating a new issue.', (\App\Settings::getInstance()->isDocker() ? 'Docker' : 'Ansible')) ?></p>
|
||||
<p><?=__('Your current installation type is <b>%s</b>. Be sure to include this when creating a new issue.',
|
||||
($environment->isDocker() ? 'Docker' : 'Ansible'))?></p>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<a class="btn btn-outline-primary" role="button" href="https://github.com/AzuraCast/AzuraCast/issues/new/choose" target="_blank">
|
||||
<i class="material-icons" aria-hidden="true">contact_support</i>
|
||||
<?=__('Add New GitHub Issue') ?>
|
||||
<?=__('Add New GitHub Issue')?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Settings;
|
||||
use App\Environment;
|
||||
|
||||
class C02_Station_MediaCest extends CestAbstract
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ class C02_Station_MediaCest extends CestAbstract
|
|||
$station_id = $testStation->getId();
|
||||
|
||||
// Upload test song
|
||||
$test_song_orig = $this->settings[Settings::BASE_DIR] . '/resources/error.mp3';
|
||||
$test_song_orig = $this->environment[Environment::BASE_DIR] . '/resources/error.mp3';
|
||||
$I->sendPOST('/api/station/' . $station_id . '/files', [
|
||||
'path' => 'error.mp3',
|
||||
'file' => base64_encode(file_get_contents($test_song_orig)),
|
||||
|
|
|
@ -8,7 +8,7 @@ abstract class CestAbstract
|
|||
{
|
||||
protected ContainerInterface $di;
|
||||
|
||||
protected App\Settings $settings;
|
||||
protected App\Environment $environment;
|
||||
|
||||
protected Entity\Repository\SettingsRepository $settingsRepo;
|
||||
|
||||
|
@ -27,7 +27,7 @@ abstract class CestAbstract
|
|||
|
||||
$this->settingsRepo = $this->di->get(Entity\Repository\SettingsRepository::class);
|
||||
$this->stationRepo = $this->di->get(Entity\Repository\StationRepository::class);
|
||||
$this->settings = $this->di->get(App\Settings::class);
|
||||
$this->environment = $this->di->get(App\Environment::class);
|
||||
}
|
||||
|
||||
public function _after(FunctionalTester $I): void
|
||||
|
|
|
@ -9,7 +9,7 @@ ini_set('display_errors', 1);
|
|||
$autoloader = require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
$app = App\AppFactory::create($autoloader, [
|
||||
App\Settings::BASE_DIR => dirname(__DIR__),
|
||||
App\Environment::BASE_DIR => dirname(__DIR__),
|
||||
]);
|
||||
|
||||
$di = $app->getContainer();
|
||||
|
|
|
@ -5,7 +5,7 @@ ini_set('display_errors', 1);
|
|||
$autoloader = require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
$app = App\AppFactory::create($autoloader, [
|
||||
App\Settings::BASE_DIR => dirname(__DIR__),
|
||||
App\Environment::BASE_DIR => dirname(__DIR__),
|
||||
]);
|
||||
|
||||
$app->run();
|
||||
|
|
Loading…
Reference in New Issue