Visual Console Refactor: error fixes

Former-commit-id: 5cfe645c4b02e84b9b2e9056747419bf144b0594
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-04 17:03:56 +02:00
parent ead487b24b
commit 418d73b003
2 changed files with 11 additions and 4 deletions

View File

@ -225,11 +225,17 @@ final class ColorCloud extends Item
if (empty($dynamicData['colorRanges']) === false) { if (empty($dynamicData['colorRanges']) === false) {
// Connect to node. // Connect to node.
$nodeConnected = false; $nodeConnected = false;
if (is_metaconsole() === true && $metaconsoleId !== null) { if (\is_metaconsole() === true && $metaconsoleId !== null) {
$nodeConnected = metaconsole_connect( $nodeConnected = \metaconsole_connect(
null, null,
$metaconsoleId $metaconsoleId
) === NOERR; ) === NOERR;
if ($nodeConnected === false) {
throw new \InvalidArgumentException(
'error connecting to the node'
);
}
} }
// Fetch module value. // Fetch module value.
@ -237,12 +243,12 @@ final class ColorCloud extends Item
if ($metaconsoleId === null if ($metaconsoleId === null
|| ($metaconsoleId !== null && $nodeConnected) || ($metaconsoleId !== null && $nodeConnected)
) { ) {
$value = modules_get_last_value($moduleId); $value = \modules_get_last_value($moduleId);
} }
// Restore connection. // Restore connection.
if ($nodeConnected === true) { if ($nodeConnected === true) {
metaconsole_restore_db(); \metaconsole_restore_db();
} }
// Value found. // Value found.

View File

@ -165,6 +165,7 @@ final class SimpleValue extends Item
throw new \InvalidArgumentException('missing module Id'); throw new \InvalidArgumentException('missing module Id');
} }
// TODO: Connect to a metaconsole node?
// Get the formatted value. // Get the formatted value.
$value = \visual_map_get_simple_value( $value = \visual_map_get_simple_value(
$data['type'], $data['type'],