diff --git a/CHANGELOG.md b/CHANGELOG.md index 308790a6..4c117620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this #### Changed +* [#342](https://github.com/shlinkio/shlink/issues/342) The installer no longer asks for a charset to be provided, and instead, it shuffles the base62 charset. * [#320](https://github.com/shlinkio/shlink/issues/320) Replaced query builder by plain DQL for all queries which do not need to be dynamically generated. * [#330](https://github.com/shlinkio/shlink/issues/330) No longer allow failures on PHP 7.3 envs during project CI build. * [#335](https://github.com/shlinkio/shlink/issues/335) Renamed functional test suite to database test suite, since that better describes what it actually does. diff --git a/config/install-container.php b/config/install-container.php index ca3d273a..f26b7598 100644 --- a/config/install-container.php +++ b/config/install-container.php @@ -14,21 +14,35 @@ chdir(dirname(__DIR__)); require __DIR__ . '/../vendor/autoload.php'; -$container = new ServiceManager([ - 'factories' => [ - Application::class => InstallApplicationFactory::class, - Filesystem::class => InvokableFactory::class, - ], - 'services' => [ - 'random-chars-generator' => function () { - return str_shuffle(UrlShortenerOptions::DEFAULT_CHARS); - }, - 'config' => [ - ConfigAbstractFactory::class => [ - Plugin\DatabaseConfigCustomizer::class => [Filesystem::class], - Plugin\UrlShortenerConfigCustomizer::class => ['random-chars-generator'], - ], +$config = [ + 'dependencies' => [ + 'factories' => [ + Application::class => InstallApplicationFactory::class, + Filesystem::class => InvokableFactory::class, + ], + 'services' => [ + 'random-chars-generator' => function () { + return str_shuffle(UrlShortenerOptions::DEFAULT_CHARS); + }, ], ], -]); + + 'config_customizer_plugins' => [ + 'factories' => [ + Plugin\DatabaseConfigCustomizer::class => ConfigAbstractFactory::class, + Plugin\UrlShortenerConfigCustomizer::class => ConfigAbstractFactory::class, + Plugin\LanguageConfigCustomizer::class => InvokableFactory::class, + Plugin\ApplicationConfigCustomizer::class => InvokableFactory::class, + ], + ], + + ConfigAbstractFactory::class => [ + Plugin\DatabaseConfigCustomizer::class => [Filesystem::class], + Plugin\UrlShortenerConfigCustomizer::class => ['random-chars-generator'], + ], +]; + +$container = new ServiceManager($config['dependencies']); +$container->setService('config', $config); + return $container; diff --git a/module/Installer/src/Factory/InstallApplicationFactory.php b/module/Installer/src/Factory/InstallApplicationFactory.php index 728cf716..ac994144 100644 --- a/module/Installer/src/Factory/InstallApplicationFactory.php +++ b/module/Installer/src/Factory/InstallApplicationFactory.php @@ -7,16 +7,13 @@ use Interop\Container\ContainerInterface; use Interop\Container\Exception\ContainerException; use Shlinkio\Shlink\Installer\Command\InstallCommand; use Shlinkio\Shlink\Installer\Config\ConfigCustomizerManager; -use Shlinkio\Shlink\Installer\Config\Plugin; use Symfony\Component\Console\Application; use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Filesystem\Filesystem; use Zend\Config\Writer\PhpArray; -use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory; use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Factory\FactoryInterface; -use Zend\ServiceManager\Factory\InvokableFactory; class InstallApplicationFactory implements FactoryInterface { @@ -41,12 +38,7 @@ class InstallApplicationFactory implements FactoryInterface $command = new InstallCommand( new PhpArray(), $container->get(Filesystem::class), - new ConfigCustomizerManager($container, ['factories' => [ - Plugin\DatabaseConfigCustomizer::class => ConfigAbstractFactory::class, - Plugin\UrlShortenerConfigCustomizer::class => ConfigAbstractFactory::class, - Plugin\LanguageConfigCustomizer::class => InvokableFactory::class, - Plugin\ApplicationConfigCustomizer::class => InvokableFactory::class, - ]]), + new ConfigCustomizerManager($container, $container->get('config')['config_customizer_plugins']), $isUpdate ); $app->add($command); diff --git a/module/Installer/test/Factory/InstallApplicationFactoryTest.php b/module/Installer/test/Factory/InstallApplicationFactoryTest.php index a4f3ce3d..326dd251 100644 --- a/module/Installer/test/Factory/InstallApplicationFactoryTest.php +++ b/module/Installer/test/Factory/InstallApplicationFactoryTest.php @@ -14,7 +14,7 @@ class InstallApplicationFactoryTest extends TestCase /** @var InstallApplicationFactory */ private $factory; - public function setUp() + public function setUp(): void { $this->factory = new InstallApplicationFactory(); } @@ -22,10 +22,11 @@ class InstallApplicationFactoryTest extends TestCase /** * @test */ - public function serviceIsCreated() + public function serviceIsCreated(): void { - $instance = $this->factory->__invoke(new ServiceManager(['services' => [ + $instance = ($this->factory)(new ServiceManager(['services' => [ Filesystem::class => $this->prophesize(Filesystem::class)->reveal(), + 'config' => ['config_customizer_plugins' => []], ]]), ''); $this->assertInstanceOf(Application::class, $instance);