Visual Console Refactor: bugfixes

Former-commit-id: d5f194be2d9e201cdcc3c7cafbd64b6a1149ae7d
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-17 15:58:07 +02:00
parent 161bf4c079
commit c9076aa85e
2 changed files with 9 additions and 10 deletions

View File

@ -446,11 +446,10 @@ class Item extends Model
{ {
$agentData = []; $agentData = [];
// We should add the metaconsole Id if we can. If not, // We should add the metaconsole Id if we can.
// it doesn't have to be into the structure.
$metaconsoleId = static::extractMetaconsoleId($data); $metaconsoleId = static::extractMetaconsoleId($data);
if ($metaconsoleId !== null) { if ($metaconsoleId !== null && $metaconsoleId <= 0) {
$agentData['metaconsoleId'] = $metaconsoleId; $agentData['metaconsoleId'] = null;
} }
// The agent Id should be a valid int or a null value. // The agent Id should be a valid int or a null value.

View File

@ -44,7 +44,10 @@ final class ColorCloud extends Item
$decodedData['label'] = null; $decodedData['label'] = null;
$decodedData['defaultColor'] = static::extractDefaultColor($data); $decodedData['defaultColor'] = static::extractDefaultColor($data);
$decodedData['colorRanges'] = static::extractColorRanges($data); $decodedData['colorRanges'] = static::extractColorRanges($data);
$decodedData['color'] = static::notEmptyStringOr(static::issetInArray($data, ['color']), null); $decodedData['color'] = static::notEmptyStringOr(
static::issetInArray($data, ['color']),
null
);
return $decodedData; return $decodedData;
} }
@ -204,11 +207,8 @@ final class ColorCloud extends Item
// Get the linked module Id. // Get the linked module Id.
$linkedModule = static::extractLinkedModule($data); $linkedModule = static::extractLinkedModule($data);
$moduleId = static::parseIntOr($linkedModule['moduleId'], null); $moduleId = $linkedModule['moduleId'];
$metaconsoleId = static::parseIntOr( $metaconsoleId = $linkedModule['metaconsoleId'];
$linkedModule['metaconsoleId'],
null
);
if ($moduleId === null) { if ($moduleId === null) {
throw new \InvalidArgumentException('missing module Id'); throw new \InvalidArgumentException('missing module Id');