Skip to content

Commit

Permalink
Merge pull request #2 from ipublikuj/console-opt
Browse files Browse the repository at this point in the history
Feature: Make console optional
  • Loading branch information
akadlec authored Nov 10, 2019
2 parents 587a55f + 4c06c9f commit 958a853
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
21 changes: 12 additions & 9 deletions src/IPub/MQTTClient/DI/MQTTClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ final class MQTTClientExtension extends DI\CompilerExtension
'clean' => TRUE,
],
'loop' => NULL,
'console' => FALSE,
];

/**
Expand Down Expand Up @@ -111,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'],
Expand All @@ -131,17 +132,19 @@ public function loadConfiguration()
->setType(Client\Client::class)
->setArguments([
'eventLoop' => $loop,
'configuration' => $configuration,
'configuration' => $clientConfiguration,
]);

// 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);
}
}
}

Expand Down
11 changes: 0 additions & 11 deletions tests/IPubTests/MQTTClient/files/config.neon
Original file line number Diff line number Diff line change
@@ -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: []

0 comments on commit 958a853

Please sign in to comment.