From 0e2ad0dbca49b1e88e9f44491755e3506b2de85e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 31 Dec 2017 17:14:01 +0100 Subject: [PATCH] Updated ConfigCustomizer api to expect a SymfonyStyle object instead of a set of input and output --- module/CLI/src/Command/Install/InstallCommand.php | 2 +- .../Install/Plugin/ApplicationConfigCustomizerPlugin.php | 8 ++------ .../Install/Plugin/ConfigCustomizerPluginInterface.php | 8 +++----- .../Install/Plugin/DatabaseConfigCustomizerPlugin.php | 8 ++------ .../Install/Plugin/LanguageConfigCustomizerPlugin.php | 8 ++------ .../Plugin/UrlShortenerConfigCustomizerPlugin.php | 8 ++------ .../Plugin/ApplicationConfigCustomizerPluginTest.php | 7 ++++--- .../Plugin/DatabaseConfigCustomizerPluginTest.php | 9 +++++---- .../Plugin/LanguageConfigCustomizerPluginTest.php | 7 ++++--- .../Plugin/UrlShortenerConfigCustomizerPluginTest.php | 7 ++++--- 10 files changed, 29 insertions(+), 43 deletions(-) diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php index 1784875b..0b641834 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -123,7 +123,7 @@ class InstallCommand extends Command ] as $pluginName) { /** @var Plugin\ConfigCustomizerPluginInterface $configCustomizer */ $configCustomizer = $this->configCustomizers->get($pluginName); - $configCustomizer->process($input, $output, $config); + $configCustomizer->process($this->io, $config); } // Generate config params files diff --git a/module/CLI/src/Install/Plugin/ApplicationConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/ApplicationConfigCustomizerPlugin.php index 232fe048..b507e652 100644 --- a/module/CLI/src/Install/Plugin/ApplicationConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/ApplicationConfigCustomizerPlugin.php @@ -5,8 +5,6 @@ namespace Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; use Shlinkio\Shlink\Common\Util\StringUtilsTrait; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; class ApplicationConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin @@ -14,14 +12,12 @@ class ApplicationConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin use StringUtilsTrait; /** - * @param InputInterface $input - * @param OutputInterface $output + * @param SymfonyStyle $io * @param CustomizableAppConfig $appConfig * @return void */ - public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) { - $io = new SymfonyStyle($input, $output); $io->title('APPLICATION'); if ($appConfig->hasApp() && $io->confirm('Do you want to keep imported application config?')) { diff --git a/module/CLI/src/Install/Plugin/ConfigCustomizerPluginInterface.php b/module/CLI/src/Install/Plugin/ConfigCustomizerPluginInterface.php index 5ad702fb..88c08f29 100644 --- a/module/CLI/src/Install/Plugin/ConfigCustomizerPluginInterface.php +++ b/module/CLI/src/Install/Plugin/ConfigCustomizerPluginInterface.php @@ -4,16 +4,14 @@ declare(strict_types=1); namespace Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; interface ConfigCustomizerPluginInterface { /** - * @param InputInterface $input - * @param OutputInterface $output + * @param SymfonyStyle $io * @param CustomizableAppConfig $appConfig * @return void */ - public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig); + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig); } diff --git a/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php index edb843d0..faf8c805 100644 --- a/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/DatabaseConfigCustomizerPlugin.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; @@ -29,15 +27,13 @@ class DatabaseConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin } /** - * @param InputInterface $input - * @param OutputInterface $output + * @param SymfonyStyle $io * @param CustomizableAppConfig $appConfig * @return void * @throws IOException */ - public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) { - $io = new SymfonyStyle($input, $output); $io->title('DATABASE'); if ($appConfig->hasDatabase() && $io->confirm('Do you want to keep imported database config?')) { diff --git a/module/CLI/src/Install/Plugin/LanguageConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/LanguageConfigCustomizerPlugin.php index 5f37fd65..d33c9f43 100644 --- a/module/CLI/src/Install/Plugin/LanguageConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/LanguageConfigCustomizerPlugin.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; class LanguageConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin @@ -13,14 +11,12 @@ class LanguageConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin const SUPPORTED_LANGUAGES = ['en', 'es']; /** - * @param InputInterface $input - * @param OutputInterface $output + * @param SymfonyStyle $io * @param CustomizableAppConfig $appConfig * @return void */ - public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) { - $io = new SymfonyStyle($input, $output); $io->title('LANGUAGE'); if ($appConfig->hasLanguage() && $io->confirm('Do you want to keep imported language?')) { diff --git a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php b/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php index 2be57759..b8ef1b8b 100644 --- a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php +++ b/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizerPlugin.php @@ -5,21 +5,17 @@ namespace Shlinkio\Shlink\CLI\Install\Plugin; use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig; use Shlinkio\Shlink\Core\Service\UrlShortener; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; class UrlShortenerConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin { /** - * @param InputInterface $input - * @param OutputInterface $output + * @param SymfonyStyle $io * @param CustomizableAppConfig $appConfig * @return void */ - public function process(InputInterface $input, OutputInterface $output, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) { - $io = new SymfonyStyle($input, $output); $io->title('URL SHORTENER'); if ($appConfig->hasUrlShortener() && $io->confirm('Do you want to keep imported URL shortener config?')) { diff --git a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerPluginTest.php b/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerPluginTest.php index 675dade7..96c60fef 100644 --- a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerPluginTest.php +++ b/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerPluginTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Style\SymfonyStyle; class ApplicationConfigCustomizerPluginTest extends TestCase { @@ -40,7 +41,7 @@ class ApplicationConfigCustomizerPluginTest extends TestCase $askSecret = $this->questionHelper->ask(Argument::cetera())->willReturn('the_secret'); $config = new CustomizableAppConfig(); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertTrue($config->hasApp()); $this->assertEquals([ @@ -64,7 +65,7 @@ class ApplicationConfigCustomizerPluginTest extends TestCase 'SECRET' => 'foo', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'SECRET' => 'the_new_secret', @@ -85,7 +86,7 @@ class ApplicationConfigCustomizerPluginTest extends TestCase 'SECRET' => 'foo', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'SECRET' => 'foo', diff --git a/module/CLI/test/Install/Plugin/DatabaseConfigCustomizerPluginTest.php b/module/CLI/test/Install/Plugin/DatabaseConfigCustomizerPluginTest.php index bfaf2491..267f309a 100644 --- a/module/CLI/test/Install/Plugin/DatabaseConfigCustomizerPluginTest.php +++ b/module/CLI/test/Install/Plugin/DatabaseConfigCustomizerPluginTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Filesystem; class DatabaseConfigCustomizerPluginTest extends TestCase @@ -50,7 +51,7 @@ class DatabaseConfigCustomizerPluginTest extends TestCase $askSecret = $this->questionHelper->ask(Argument::cetera())->willReturn('MySQL'); $config = new CustomizableAppConfig(); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertTrue($config->hasDatabase()); $this->assertEquals([ @@ -84,7 +85,7 @@ class DatabaseConfigCustomizerPluginTest extends TestCase 'PORT' => 'MySQL', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'DRIVER' => 'pdo_mysql', @@ -115,7 +116,7 @@ class DatabaseConfigCustomizerPluginTest extends TestCase 'PORT' => 'MySQL', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'DRIVER' => 'pdo_pgsql', @@ -143,7 +144,7 @@ class DatabaseConfigCustomizerPluginTest extends TestCase 'DRIVER' => 'pdo_sqlite', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'DRIVER' => 'pdo_sqlite', diff --git a/module/CLI/test/Install/Plugin/LanguageConfigCustomizerPluginTest.php b/module/CLI/test/Install/Plugin/LanguageConfigCustomizerPluginTest.php index 0edc382e..eb81d22d 100644 --- a/module/CLI/test/Install/Plugin/LanguageConfigCustomizerPluginTest.php +++ b/module/CLI/test/Install/Plugin/LanguageConfigCustomizerPluginTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Style\SymfonyStyle; class LanguageConfigCustomizerPluginTest extends TestCase { @@ -40,7 +41,7 @@ class LanguageConfigCustomizerPluginTest extends TestCase $askSecret = $this->questionHelper->ask(Argument::cetera())->willReturn('en'); $config = new CustomizableAppConfig(); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertTrue($config->hasLanguage()); $this->assertEquals([ @@ -66,7 +67,7 @@ class LanguageConfigCustomizerPluginTest extends TestCase 'CLI' => 'en', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'DEFAULT' => 'es', @@ -89,7 +90,7 @@ class LanguageConfigCustomizerPluginTest extends TestCase 'CLI' => 'es', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'DEFAULT' => 'es', diff --git a/module/CLI/test/Install/Plugin/UrlShortenerConfigCustomizerPluginTest.php b/module/CLI/test/Install/Plugin/UrlShortenerConfigCustomizerPluginTest.php index 2c396db2..6a22b713 100644 --- a/module/CLI/test/Install/Plugin/UrlShortenerConfigCustomizerPluginTest.php +++ b/module/CLI/test/Install/Plugin/UrlShortenerConfigCustomizerPluginTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Style\SymfonyStyle; class UrlShortenerConfigCustomizerPluginTest extends TestCase { @@ -40,7 +41,7 @@ class UrlShortenerConfigCustomizerPluginTest extends TestCase $askSecret = $this->questionHelper->ask(Argument::cetera())->willReturn('something'); $config = new CustomizableAppConfig(); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertTrue($config->hasUrlShortener()); $this->assertEquals([ @@ -70,7 +71,7 @@ class UrlShortenerConfigCustomizerPluginTest extends TestCase 'VALIDATE_URL' => 'bar', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'SCHEMA' => 'foo', @@ -97,7 +98,7 @@ class UrlShortenerConfigCustomizerPluginTest extends TestCase 'VALIDATE_URL' => 'foo', ]); - $this->plugin->process(new ArrayInput([]), new NullOutput(), $config); + $this->plugin->process(new SymfonyStyle(new ArrayInput([]), new NullOutput()), $config); $this->assertEquals([ 'SCHEMA' => 'foo',