Skip to content

Commit

Permalink
Remove app_options config
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Oct 24, 2024
1 parent f3244b3 commit a3ea8f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down
14 changes: 0 additions & 14 deletions config/autoload/app_options.global.php

This file was deleted.

3 changes: 1 addition & 2 deletions module/Core/config/dependencies.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;
Expand All @@ -24,7 +23,7 @@
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'],
Expand Down
10 changes: 9 additions & 1 deletion module/Core/src/Config/Options/AppOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@

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

Check warning on line 17 in module/Core/src/Config/Options/AppOptions.php

View check run for this annotation

Codecov / codecov/patch

module/Core/src/Config/Options/AppOptions.php#L17

Added line #L17 was not covered by tests
{
$version = EnvVars::isDevEnv() ? 'latest' : '%SHLINK_VERSION%';
return new self(version: $version);

Check warning on line 20 in module/Core/src/Config/Options/AppOptions.php

View check run for this annotation

Codecov / codecov/patch

module/Core/src/Config/Options/AppOptions.php#L19-L20

Added lines #L19 - L20 were not covered by tests
}

public function __toString(): string

Check warning on line 23 in module/Core/src/Config/Options/AppOptions.php

View check run for this annotation

Codecov / codecov/patch

module/Core/src/Config/Options/AppOptions.php#L23

Added line #L23 was not covered by tests
Expand Down

0 comments on commit a3ea8f5

Please sign in to comment.