2019-09-12 07:31:01 +02:00
|
|
|
<?php
|
2020-10-15 00:19:31 +02:00
|
|
|
|
2021-07-19 07:53:45 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-09-12 07:31:01 +02:00
|
|
|
namespace App;
|
|
|
|
|
2022-01-17 05:45:07 +01:00
|
|
|
use App\Enums\ApplicationEnvironment;
|
|
|
|
use App\Enums\ReleaseChannel;
|
2020-12-05 16:18:44 +01:00
|
|
|
use App\Radio\Configuration;
|
2023-11-02 14:22:32 +01:00
|
|
|
use App\Utilities\File;
|
2023-12-04 07:48:40 +01:00
|
|
|
use App\Utilities\Types;
|
2022-01-28 02:33:07 +01:00
|
|
|
use GuzzleHttp\Psr7\Uri;
|
|
|
|
use Psr\Http\Message\UriInterface;
|
2020-12-15 14:44:20 +01:00
|
|
|
use Psr\Log\LogLevel;
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2022-06-20 02:27:59 +02:00
|
|
|
final class Environment
|
2019-09-12 07:31:01 +02:00
|
|
|
{
|
2022-06-20 02:27:59 +02:00
|
|
|
private static Environment $instance;
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2023-11-02 14:22:32 +01:00
|
|
|
// Cached immutable values that are frequently used.
|
|
|
|
private readonly string $baseDir;
|
|
|
|
private readonly string $parentDir;
|
|
|
|
private readonly bool $isDocker;
|
|
|
|
private readonly ApplicationEnvironment $appEnv;
|
|
|
|
|
2023-12-04 07:48:40 +01:00
|
|
|
/** @var array<string, string|int|bool|float> */
|
2023-11-02 14:22:32 +01:00
|
|
|
private readonly array $data;
|
2020-12-06 12:57:39 +01:00
|
|
|
|
2020-02-06 03:35:13 +01:00
|
|
|
// Core settings values
|
2020-12-06 08:55:25 +01:00
|
|
|
public const APP_NAME = 'APP_NAME';
|
2020-12-05 16:18:44 +01:00
|
|
|
public const APP_ENV = 'APPLICATION_ENV';
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2020-12-06 08:55:25 +01:00
|
|
|
public const TEMP_DIR = 'TEMP_DIR';
|
2021-07-30 08:20:14 +02:00
|
|
|
public const UPLOADS_DIR = 'UPLOADS_DIR';
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2020-12-06 08:55:25 +01:00
|
|
|
public const IS_DOCKER = 'IS_DOCKER';
|
|
|
|
public const IS_CLI = 'IS_CLI';
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2020-12-06 08:55:25 +01:00
|
|
|
public const ASSET_URL = 'ASSETS_URL';
|
2020-02-06 03:35:13 +01:00
|
|
|
|
2020-12-05 16:18:44 +01:00
|
|
|
public const LANG = 'LANG';
|
|
|
|
|
|
|
|
public const RELEASE_CHANNEL = 'AZURACAST_VERSION';
|
|
|
|
|
|
|
|
public const SFTP_PORT = 'AZURACAST_SFTP_PORT';
|
|
|
|
|
|
|
|
public const AUTO_ASSIGN_PORT_MIN = 'AUTO_ASSIGN_PORT_MIN';
|
|
|
|
public const AUTO_ASSIGN_PORT_MAX = 'AUTO_ASSIGN_PORT_MAX';
|
|
|
|
|
|
|
|
public const SYNC_SHORT_EXECUTION_TIME = 'SYNC_SHORT_EXECUTION_TIME';
|
|
|
|
public const SYNC_LONG_EXECUTION_TIME = 'SYNC_LONG_EXECUTION_TIME';
|
2023-01-17 09:34:00 +01:00
|
|
|
public const NOW_PLAYING_DELAY_TIME = 'NOW_PLAYING_DELAY_TIME';
|
2023-07-14 00:28:55 +02:00
|
|
|
public const NOW_PLAYING_MAX_CONCURRENT_PROCESSES = 'NOW_PLAYING_MAX_CONCURRENT_PROCESSES';
|
2020-05-27 09:36:30 +02:00
|
|
|
|
2020-12-15 14:44:20 +01:00
|
|
|
public const LOG_LEVEL = 'LOG_LEVEL';
|
2022-03-26 03:49:56 +01:00
|
|
|
public const SHOW_DETAILED_ERRORS = 'SHOW_DETAILED_ERRORS';
|
2020-12-15 14:44:20 +01:00
|
|
|
|
2021-04-18 07:03:22 +02:00
|
|
|
public const PROFILING_EXTENSION_ENABLED = 'PROFILING_EXTENSION_ENABLED';
|
|
|
|
public const PROFILING_EXTENSION_ALWAYS_ON = 'PROFILING_EXTENSION_ALWAYS_ON';
|
|
|
|
public const PROFILING_EXTENSION_HTTP_KEY = 'PROFILING_EXTENSION_HTTP_KEY';
|
|
|
|
|
2023-01-05 19:54:03 +01:00
|
|
|
public const ENABLE_WEB_UPDATER = 'ENABLE_WEB_UPDATER';
|
|
|
|
|
2021-01-21 20:32:47 +01:00
|
|
|
// Database and Cache Configuration Variables
|
|
|
|
public const DB_HOST = 'MYSQL_HOST';
|
|
|
|
public const DB_PORT = 'MYSQL_PORT';
|
|
|
|
public const DB_NAME = 'MYSQL_DATABASE';
|
|
|
|
public const DB_USER = 'MYSQL_USER';
|
|
|
|
public const DB_PASSWORD = 'MYSQL_PASSWORD';
|
|
|
|
|
2022-12-06 15:45:43 +01:00
|
|
|
public const ENABLE_REDIS = 'ENABLE_REDIS';
|
|
|
|
public const REDIS_HOST = 'REDIS_HOST';
|
|
|
|
public const REDIS_PORT = 'REDIS_PORT';
|
|
|
|
|
2020-07-10 10:18:10 +02:00
|
|
|
public function __construct(array $elements = [])
|
|
|
|
{
|
2023-11-02 14:22:32 +01:00
|
|
|
$this->baseDir = dirname(__DIR__);
|
|
|
|
$this->parentDir = dirname($this->baseDir);
|
|
|
|
$this->isDocker = file_exists($this->parentDir . '/.docker');
|
|
|
|
|
2023-12-04 07:48:40 +01:00
|
|
|
$this->data = $elements;
|
|
|
|
$this->appEnv = ApplicationEnvironment::tryFrom(
|
|
|
|
Types::string($this->data[self::APP_ENV] ?? null, '', true)
|
|
|
|
) ?? ApplicationEnvironment::default();
|
2020-12-06 12:57:39 +01:00
|
|
|
}
|
|
|
|
|
2021-07-08 22:03:54 +02:00
|
|
|
public function toArray(): array
|
|
|
|
{
|
|
|
|
return $this->data;
|
|
|
|
}
|
|
|
|
|
2022-01-17 05:45:07 +01:00
|
|
|
public function getAppEnvironmentEnum(): ApplicationEnvironment
|
2020-12-06 12:57:39 +01:00
|
|
|
{
|
2023-11-02 14:22:32 +01:00
|
|
|
return $this->appEnv;
|
2020-07-10 10:18:10 +02:00
|
|
|
}
|
|
|
|
|
2023-12-04 07:48:40 +01:00
|
|
|
/**
|
|
|
|
* @return string The base directory of the application, i.e. `/var/app/www` for Docker installations.
|
|
|
|
*/
|
|
|
|
public function getBaseDirectory(): string
|
|
|
|
{
|
|
|
|
return $this->baseDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string The parent directory the application is within, i.e. `/var/azuracast`.
|
|
|
|
*/
|
|
|
|
public function getParentDirectory(): string
|
|
|
|
{
|
|
|
|
return $this->parentDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isDocker(): bool
|
|
|
|
{
|
|
|
|
return $this->isDocker;
|
|
|
|
}
|
|
|
|
|
2020-02-06 03:35:13 +01:00
|
|
|
public function isProduction(): bool
|
|
|
|
{
|
2022-01-17 05:45:07 +01:00
|
|
|
return ApplicationEnvironment::Production === $this->getAppEnvironmentEnum();
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isTesting(): bool
|
|
|
|
{
|
2022-01-17 05:45:07 +01:00
|
|
|
return ApplicationEnvironment::Testing === $this->getAppEnvironmentEnum();
|
2020-12-06 12:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isDevelopment(): bool
|
|
|
|
{
|
2022-01-17 05:45:07 +01:00
|
|
|
return ApplicationEnvironment::Development === $this->getAppEnvironmentEnum();
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
2022-03-26 03:36:49 +01:00
|
|
|
public function showDetailedErrors(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::SHOW_DETAILED_ERRORS] ?? null,
|
|
|
|
!$this->isProduction(),
|
|
|
|
true
|
|
|
|
);
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isCli(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::IS_CLI] ?? null,
|
|
|
|
('cli' === PHP_SAPI)
|
|
|
|
);
|
2020-12-06 12:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getAppName(): string
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::string(
|
|
|
|
$this->data[self::APP_NAME] ?? null,
|
|
|
|
'AzuraCast',
|
|
|
|
true
|
|
|
|
);
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
2020-12-06 08:55:25 +01:00
|
|
|
public function getAssetUrl(): ?string
|
2020-02-06 03:35:13 +01:00
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::string(
|
|
|
|
$this->data[self::ASSET_URL] ?? null,
|
|
|
|
'/static',
|
|
|
|
true
|
|
|
|
);
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-11-02 14:22:32 +01:00
|
|
|
* @return string The directory where temporary files are stored by the application, i.e. `/var/app/www_tmp`
|
2020-02-06 03:35:13 +01:00
|
|
|
*/
|
2023-11-02 14:22:32 +01:00
|
|
|
public function getTempDirectory(): string
|
2020-02-06 03:35:13 +01:00
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::string(
|
|
|
|
$this->data[self::TEMP_DIR] ?? null,
|
|
|
|
$this->getParentDirectory() . '/www_tmp',
|
|
|
|
true
|
|
|
|
);
|
2020-02-06 03:35:13 +01:00
|
|
|
}
|
|
|
|
|
2021-07-30 08:20:14 +02:00
|
|
|
/**
|
|
|
|
* @return string The directory where user system-level uploads are stored.
|
|
|
|
*/
|
|
|
|
public function getUploadsDirectory(): string
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::string(
|
|
|
|
$this->data[self::UPLOADS_DIR] ?? null,
|
|
|
|
File::getFirstExistingDirectory([
|
|
|
|
$this->getParentDirectory() . '/storage/uploads',
|
|
|
|
$this->getParentDirectory() . '/uploads',
|
|
|
|
]),
|
|
|
|
true
|
|
|
|
);
|
2019-09-12 07:31:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string The default directory where station data is stored.
|
|
|
|
*/
|
|
|
|
public function getStationDirectory(): string
|
|
|
|
{
|
2019-09-20 18:44:38 +02:00
|
|
|
return $this->getParentDirectory() . '/stations';
|
2019-09-12 07:31:01 +02:00
|
|
|
}
|
|
|
|
|
2022-05-07 15:50:48 +02:00
|
|
|
public function getInternalUri(): UriInterface
|
2022-03-09 00:00:03 +01:00
|
|
|
{
|
2022-05-07 15:50:48 +02:00
|
|
|
return new Uri('http://127.0.0.1:6010');
|
2022-01-28 02:33:07 +01:00
|
|
|
}
|
|
|
|
|
2022-05-07 15:50:48 +02:00
|
|
|
public function getLocalUri(): UriInterface
|
2022-01-28 02:33:07 +01:00
|
|
|
{
|
2022-05-03 22:10:16 +02:00
|
|
|
return new Uri('http://127.0.0.1');
|
2022-01-28 02:33:07 +01:00
|
|
|
}
|
|
|
|
|
2020-12-05 16:18:44 +01:00
|
|
|
public function getLang(): ?string
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::stringOrNull($this->data[self::LANG]);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2022-01-17 05:45:07 +01:00
|
|
|
public function getReleaseChannelEnum(): ReleaseChannel
|
2020-12-05 16:18:44 +01:00
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return ReleaseChannel::tryFrom(Types::string($this->data[self::RELEASE_CHANNEL] ?? null))
|
2022-01-17 05:45:07 +01:00
|
|
|
?? ReleaseChannel::default();
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSftpPort(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::SFTP_PORT] ?? null,
|
|
|
|
2022
|
|
|
|
);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getAutoAssignPortMin(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::AUTO_ASSIGN_PORT_MIN] ?? null,
|
|
|
|
Configuration::DEFAULT_PORT_MIN
|
|
|
|
);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getAutoAssignPortMax(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::AUTO_ASSIGN_PORT_MAX] ?? null,
|
|
|
|
Configuration::DEFAULT_PORT_MAX
|
|
|
|
);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSyncShortExecutionTime(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::SYNC_SHORT_EXECUTION_TIME] ?? null,
|
|
|
|
600
|
2023-01-17 09:34:00 +01:00
|
|
|
);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getSyncLongExecutionTime(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::SYNC_LONG_EXECUTION_TIME] ?? null,
|
|
|
|
1800
|
2023-01-17 09:34:00 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getNowPlayingDelayTime(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int($this->data[self::NOW_PLAYING_DELAY_TIME] ?? null);
|
2020-12-05 16:18:44 +01:00
|
|
|
}
|
2020-12-15 14:44:20 +01:00
|
|
|
|
2023-07-14 00:28:55 +02:00
|
|
|
public function getNowPlayingMaxConcurrentProcesses(): int
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::int(
|
|
|
|
$this->data[self::NOW_PLAYING_MAX_CONCURRENT_PROCESSES] ?? null,
|
|
|
|
5
|
2023-07-14 00:28:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-23 04:08:52 +02:00
|
|
|
/**
|
|
|
|
* @phpstan-return LogLevel::*
|
|
|
|
*/
|
2020-12-15 14:44:20 +01:00
|
|
|
public function getLogLevel(): string
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
$logLevelRaw = Types::stringOrNull($this->data[self::LOG_LEVEL] ?? null, true);
|
|
|
|
if (null !== $logLevelRaw) {
|
|
|
|
$loggingLevel = strtolower($logLevelRaw);
|
2020-12-15 14:44:20 +01:00
|
|
|
$allowedLogLevels = [
|
|
|
|
LogLevel::DEBUG,
|
|
|
|
LogLevel::INFO,
|
|
|
|
LogLevel::NOTICE,
|
|
|
|
LogLevel::WARNING,
|
|
|
|
LogLevel::ERROR,
|
|
|
|
LogLevel::CRITICAL,
|
|
|
|
LogLevel::ALERT,
|
|
|
|
LogLevel::EMERGENCY,
|
|
|
|
];
|
|
|
|
|
|
|
|
if (in_array($loggingLevel, $allowedLogLevels, true)) {
|
|
|
|
return $loggingLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->isProduction()
|
|
|
|
? LogLevel::NOTICE
|
2021-02-10 01:29:43 +01:00
|
|
|
: LogLevel::INFO;
|
2020-12-15 14:44:20 +01:00
|
|
|
}
|
2021-01-21 20:32:47 +01:00
|
|
|
|
2021-01-21 20:48:47 +01:00
|
|
|
/**
|
2023-12-04 07:48:40 +01:00
|
|
|
* @return array{
|
|
|
|
* host: string,
|
|
|
|
* port: int,
|
|
|
|
* dbname: string,
|
|
|
|
* user: string,
|
|
|
|
* password: string,
|
|
|
|
* unix_socket?: string
|
|
|
|
* }
|
2021-01-21 20:48:47 +01:00
|
|
|
*/
|
2021-01-21 20:32:47 +01:00
|
|
|
public function getDatabaseSettings(): array
|
|
|
|
{
|
2022-05-07 15:50:48 +02:00
|
|
|
$dbSettings = [
|
2023-12-04 07:48:40 +01:00
|
|
|
'host' => Types::string(
|
|
|
|
$this->data[self::DB_HOST] ?? null,
|
|
|
|
'localhost',
|
|
|
|
true
|
|
|
|
),
|
|
|
|
'port' => Types::int(
|
|
|
|
$this->data[self::DB_PORT] ?? null,
|
|
|
|
3306
|
|
|
|
),
|
|
|
|
'dbname' => Types::string(
|
|
|
|
$this->data[self::DB_NAME] ?? null,
|
|
|
|
'azuracast',
|
|
|
|
true
|
|
|
|
),
|
|
|
|
'user' => Types::string(
|
|
|
|
$this->data[self::DB_USER] ?? null,
|
|
|
|
'azuracast',
|
|
|
|
true
|
|
|
|
),
|
|
|
|
'password' => Types::string(
|
|
|
|
$this->data[self::DB_PASSWORD] ?? null,
|
|
|
|
'azur4c457',
|
|
|
|
true
|
|
|
|
),
|
2021-01-21 20:32:47 +01:00
|
|
|
];
|
2022-05-07 15:50:48 +02:00
|
|
|
|
2022-07-02 03:42:20 +02:00
|
|
|
if ('localhost' === $dbSettings['host'] && $this->isDocker()) {
|
2022-05-07 15:50:48 +02:00
|
|
|
$dbSettings['unix_socket'] = '/run/mysqld/mysqld.sock';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $dbSettings;
|
2021-01-21 20:32:47 +01:00
|
|
|
}
|
|
|
|
|
2022-12-06 19:52:54 +01:00
|
|
|
public function useLocalDatabase(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return 'localhost' === $this->getDatabaseSettings()['host'];
|
2022-12-06 19:52:54 +01:00
|
|
|
}
|
|
|
|
|
2022-12-06 15:45:43 +01:00
|
|
|
public function enableRedis(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::ENABLE_REDIS],
|
|
|
|
true,
|
|
|
|
true
|
|
|
|
);
|
2022-12-06 15:45:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-12-04 07:48:40 +01:00
|
|
|
* @return array{
|
|
|
|
* host: string,
|
|
|
|
* port: int,
|
|
|
|
* socket?: string
|
|
|
|
* }
|
2022-12-06 15:45:43 +01:00
|
|
|
*/
|
|
|
|
public function getRedisSettings(): array
|
2021-01-21 20:32:47 +01:00
|
|
|
{
|
2022-12-06 15:45:43 +01:00
|
|
|
$redisSettings = [
|
2023-12-04 07:48:40 +01:00
|
|
|
'host' => Types::string(
|
|
|
|
$this->data[self::REDIS_HOST] ?? null,
|
|
|
|
'localhost',
|
|
|
|
true
|
|
|
|
),
|
|
|
|
'port' => Types::int(
|
|
|
|
$this->data[self::REDIS_PORT] ?? null,
|
|
|
|
6379
|
|
|
|
),
|
2022-12-06 15:45:43 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
if ('localhost' === $redisSettings['host'] && $this->isDocker()) {
|
|
|
|
$redisSettings['socket'] = '/run/redis/redis.sock';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $redisSettings;
|
2021-01-21 20:32:47 +01:00
|
|
|
}
|
2021-04-18 07:03:22 +02:00
|
|
|
|
2022-12-06 19:52:54 +01:00
|
|
|
public function useLocalRedis(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return $this->enableRedis() && 'localhost' === $this->getRedisSettings()['host'];
|
2022-12-06 19:52:54 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 07:03:22 +02:00
|
|
|
public function isProfilingExtensionEnabled(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::PROFILING_EXTENSION_ENABLED] ?? null,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2021-04-18 07:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function isProfilingExtensionAlwaysOn(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::PROFILING_EXTENSION_ALWAYS_ON] ?? null,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2021-04-18 07:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getProfilingExtensionHttpKey(): string
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
return Types::string(
|
|
|
|
$this->data[self::PROFILING_EXTENSION_HTTP_KEY] ?? null,
|
|
|
|
'dev',
|
|
|
|
true
|
|
|
|
);
|
2021-04-18 07:03:22 +02:00
|
|
|
}
|
2021-07-23 04:31:49 +02:00
|
|
|
|
2023-01-05 19:54:03 +01:00
|
|
|
public function enableWebUpdater(): bool
|
|
|
|
{
|
2023-12-04 07:48:40 +01:00
|
|
|
if (!$this->isDocker()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Types::bool(
|
|
|
|
$this->data[self::ENABLE_WEB_UPDATER] ?? null,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2023-01-05 19:54:03 +01:00
|
|
|
}
|
|
|
|
|
2022-03-09 00:00:03 +01:00
|
|
|
public static function getDefaultsForEnvironment(Environment $existingEnv): self
|
|
|
|
{
|
|
|
|
return new self([
|
|
|
|
self::IS_CLI => $existingEnv->isCli(),
|
|
|
|
self::IS_DOCKER => $existingEnv->isDocker(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2022-06-20 02:27:59 +02:00
|
|
|
public static function getInstance(): Environment
|
|
|
|
{
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setInstance(Environment $instance): void
|
|
|
|
{
|
|
|
|
self::$instance = $instance;
|
|
|
|
}
|
2019-09-12 07:31:01 +02:00
|
|
|
}
|