Remove app_options config

This commit is contained in:
Alejandro Celaya 2024-10-24 08:49:58 +02:00
parent f3244b35e3
commit a3ea8f56dd
5 changed files with 13 additions and 20 deletions

View file

@ -43,7 +43,7 @@ RUN apk add --no-cache git && \
php composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction && \
php composer.phar clear-cache && \
rm -r docker composer.* && \
sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" module/Core/src/Config/Options/AppOptions.php
# Prepare final image

View file

@ -35,8 +35,8 @@ ${composerBin} install --no-dev --prefer-dist --optimize-autoloader --no-progres
echo 'Deleting dev files...'
rm composer.*
# Update Shlink version in config
sed -i "s/%SHLINK_VERSION%/${version}/g" config/autoload/app_options.global.php
# Update Shlink version
sed -i "s/%SHLINK_VERSION%/${version}/g" module/Core/src/Config/Options/AppOptions.php
# Compressing file
echo 'Compressing files...'

View file

@ -1,14 +0,0 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Core\Config\EnvVars;
return [
'app_options' => [
'name' => 'Shlink',
'version' => EnvVars::isDevEnv() ? 'latest' : '%SHLINK_VERSION%',
],
];

View file

@ -8,7 +8,6 @@ use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Psr\EventDispatcher\EventDispatcherInterface;
use Shlinkio\Shlink\Common\Doctrine\EntityRepositoryFactory;
use Shlinkio\Shlink\Config\Factory\ValinorConfigFactory;
use Shlinkio\Shlink\Core\Config\Options\NotFoundRedirectOptions;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
@ -24,7 +23,7 @@ return [
ErrorHandler\NotFoundRedirectHandler::class => ConfigAbstractFactory::class,
ErrorHandler\NotFoundTemplateHandler::class => InvokableFactory::class,
Config\Options\AppOptions::class => [ValinorConfigFactory::class, 'config.app_options'],
Config\Options\AppOptions::class => [Config\Options\AppOptions::class, 'fromEnv'],
Config\Options\DeleteShortUrlsOptions::class => [Config\Options\DeleteShortUrlsOptions::class, 'fromEnv'],
Config\Options\NotFoundRedirectOptions::class => [Config\Options\NotFoundRedirectOptions::class, 'fromEnv'],
Config\Options\RedirectOptions::class => [Config\Options\RedirectOptions::class, 'fromEnv'],

View file

@ -4,14 +4,22 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Config\Options;
use Shlinkio\Shlink\Core\Config\EnvVars;
use function sprintf;
final class AppOptions
{
public function __construct(public string $name = 'Shlink', public string $version = '3.0.0')
public function __construct(public string $name = 'Shlink', public string $version = '4.0.0')
{
}
public static function fromEnv(): self
{
$version = EnvVars::isDevEnv() ? 'latest' : '%SHLINK_VERSION%';
return new self(version: $version);
}
public function __toString(): string
{
return sprintf('%s:v%s', $this->name, $this->version);