2016-04-30 10:47:48 -05:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2017-10-12 03:13:20 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-01-20 13:16:37 -06:00
|
|
|
use Shlinkio\Shlink\Core\Config\EnvVars;
|
2023-01-25 13:33:07 -06:00
|
|
|
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
|
2021-08-07 04:05:20 -05:00
|
|
|
|
2021-09-26 04:20:29 -05:00
|
|
|
use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH;
|
|
|
|
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
|
2021-08-07 04:05:20 -05:00
|
|
|
|
|
|
|
return (static function (): array {
|
2021-12-10 09:24:38 -06:00
|
|
|
$shortCodesLength = max(
|
2022-04-23 05:44:17 -05:00
|
|
|
(int) EnvVars::DEFAULT_SHORT_CODES_LENGTH->loadFromEnv(DEFAULT_SHORT_CODES_LENGTH),
|
2021-12-10 09:24:38 -06:00
|
|
|
MIN_SHORT_CODES_LENGTH,
|
|
|
|
);
|
2023-01-25 13:33:07 -06:00
|
|
|
$modeFromEnv = EnvVars::SHORT_URL_MODE->loadFromEnv(ShortUrlMode::STRICT->value);
|
2024-02-12 13:29:40 -06:00
|
|
|
$mode = ShortUrlMode::tryFrom($modeFromEnv) ?? ShortUrlMode::STRICT;
|
2020-02-18 11:54:40 -06:00
|
|
|
|
2021-08-07 04:05:20 -05:00
|
|
|
return [
|
2016-04-30 10:47:48 -05:00
|
|
|
|
2021-08-07 04:05:20 -05:00
|
|
|
'url_shortener' => [
|
2022-04-23 03:32:07 -05:00
|
|
|
'domain' => [ // TODO Refactor this structure to url_shortener.schema and url_shortener.default_domain
|
2022-04-23 05:44:17 -05:00
|
|
|
'schema' => ((bool) EnvVars::IS_HTTPS_ENABLED->loadFromEnv(true)) ? 'https' : 'http',
|
|
|
|
'hostname' => EnvVars::DEFAULT_DOMAIN->loadFromEnv(''),
|
2021-08-07 04:05:20 -05:00
|
|
|
],
|
|
|
|
'default_short_codes_length' => $shortCodesLength,
|
2024-02-18 05:45:59 -06:00
|
|
|
'auto_resolve_titles' => (bool) EnvVars::AUTO_RESOLVE_TITLES->loadFromEnv(true),
|
2022-04-23 05:44:17 -05:00
|
|
|
'append_extra_path' => (bool) EnvVars::REDIRECT_APPEND_EXTRA_PATH->loadFromEnv(false),
|
2022-08-04 09:10:54 -05:00
|
|
|
'multi_segment_slugs_enabled' => (bool) EnvVars::MULTI_SEGMENT_SLUGS_ENABLED->loadFromEnv(false),
|
2022-09-30 10:19:07 -05:00
|
|
|
'trailing_slash_enabled' => (bool) EnvVars::SHORT_URL_TRAILING_SLASH->loadFromEnv(false),
|
2023-01-25 13:33:07 -06:00
|
|
|
'mode' => $mode,
|
2016-05-01 04:21:54 -05:00
|
|
|
],
|
2021-08-07 04:05:20 -05:00
|
|
|
|
|
|
|
];
|
|
|
|
})();
|