From acd8f9ac9a1299990f0f955483e6faf5047abafa Mon Sep 17 00:00:00 2001 From: Adam Kadlec Date: Sun, 10 Nov 2019 11:42:13 +0100 Subject: [PATCH 1/2] - Make console optional --- composer.json | 4 +--- src/IPub/MQTTClient/DI/MQTTClientExtension.php | 17 ++++++++++------- tests/IPubTests/MQTTClient/files/config.neon | 11 ----------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index d904f8d..c726057 100644 --- a/composer.json +++ b/composer.json @@ -53,9 +53,7 @@ "react/promise" : "~2.7", "react/socket" : "~1.2", - "psr/log" : "~1.0", - - "contributte/console" : "~0.5 || ~0.7" + "psr/log" : "~1.0" }, "require-dev" : { diff --git a/src/IPub/MQTTClient/DI/MQTTClientExtension.php b/src/IPub/MQTTClient/DI/MQTTClientExtension.php index 6cc7c04..0957390 100644 --- a/src/IPub/MQTTClient/DI/MQTTClientExtension.php +++ b/src/IPub/MQTTClient/DI/MQTTClientExtension.php @@ -71,6 +71,7 @@ final class MQTTClientExtension extends DI\CompilerExtension 'clean' => TRUE, ], 'loop' => NULL, + 'console' => FALSE, ]; /** @@ -134,14 +135,16 @@ public function loadConfiguration() 'configuration' => $configuration, ]); - // Define all console commands - $commands = [ - 'client' => Commands\ClientCommand::class, - ]; + if ($configuration['console'] === NULL) { + // Define all console commands + $commands = [ + 'client' => Commands\ClientCommand::class, + ]; - foreach ($commands as $name => $cmd) { - $builder->addDefinition($this->prefix('commands' . lcfirst($name))) - ->setType($cmd); + foreach ($commands as $name => $cmd) { + $builder->addDefinition($this->prefix('commands' . lcfirst($name))) + ->setType($cmd); + } } } diff --git a/tests/IPubTests/MQTTClient/files/config.neon b/tests/IPubTests/MQTTClient/files/config.neon index a862920..3baa847 100644 --- a/tests/IPubTests/MQTTClient/files/config.neon +++ b/tests/IPubTests/MQTTClient/files/config.neon @@ -1,13 +1,2 @@ extensions: - console: Contributte\Console\DI\ConsoleExtension(%consoleMode%) mqttClient : IPub\MQTTClient\DI\MQTTClientExtension - -console: - name: iPublikuj:Packages! - version: '1.0' - catchExceptions: true - autoExit: true - url: http://example.com - lazy: false - helperSet: \Symfony\Component\Console\Helper\HelperSet - helpers: [] From 4c06c9f7660e307b94de7df803eea644f2c91e0d Mon Sep 17 00:00:00 2001 From: Adam Kadlec Date: Sun, 10 Nov 2019 11:45:45 +0100 Subject: [PATCH 2/2] - Fixing config --- src/IPub/MQTTClient/DI/MQTTClientExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IPub/MQTTClient/DI/MQTTClientExtension.php b/src/IPub/MQTTClient/DI/MQTTClientExtension.php index 0957390..84ffda5 100644 --- a/src/IPub/MQTTClient/DI/MQTTClientExtension.php +++ b/src/IPub/MQTTClient/DI/MQTTClientExtension.php @@ -112,7 +112,7 @@ public function loadConfiguration() $configuration['connection']['clean'] ); - $configuration = new Client\Configuration( + $clientConfiguration = new Client\Configuration( $configuration['broker']['httpHost'], $configuration['broker']['port'], $configuration['broker']['address'], @@ -132,7 +132,7 @@ public function loadConfiguration() ->setType(Client\Client::class) ->setArguments([ 'eventLoop' => $loop, - 'configuration' => $configuration, + 'configuration' => $clientConfiguration, ]); if ($configuration['console'] === NULL) {