Visual Console Refactor: added missing libs
Former-commit-id: e0564527b93b844c69035f125d9e74e5baa693b7
This commit is contained in:
parent
6a378f664e
commit
35d54a7e79
|
@ -62,7 +62,7 @@ final class Container extends Model
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->extractGroupId($data);
|
static::extractGroupId($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,13 +80,13 @@ final class Container extends Model
|
||||||
return [
|
return [
|
||||||
'id' => (int) $data['id'],
|
'id' => (int) $data['id'],
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
'groupId' => $this->extractGroupId($data),
|
'groupId' => static::extractGroupId($data),
|
||||||
'backgroundImage' => $this->extractBackgroundImage($data),
|
'backgroundImage' => static::extractBackgroundImage($data),
|
||||||
'backgroundColor' => $this->extractBackgroundColor($data),
|
'backgroundColor' => static::extractBackgroundColor($data),
|
||||||
'isFavorite' => $this->extractFavorite($data),
|
'isFavorite' => static::extractFavorite($data),
|
||||||
'width' => (int) $data['width'],
|
'width' => (int) $data['width'],
|
||||||
'height' => (int) $data['height'],
|
'height' => (int) $data['height'],
|
||||||
'backgroundURL' => $this->extractBackgroundUrl($data),
|
'backgroundURL' => static::extractBackgroundUrl($data),
|
||||||
'relationLineWidth' => (int) $data['relationLineWidth'],
|
'relationLineWidth' => (int) $data['relationLineWidth'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException When a valid group Id can't be found.
|
* @throws \InvalidArgumentException When a valid group Id can't be found.
|
||||||
*/
|
*/
|
||||||
private function extractGroupId(array $data): int
|
private static function extractGroupId(array $data): int
|
||||||
{
|
{
|
||||||
$groupId = static::parseIntOr(
|
$groupId = static::parseIntOr(
|
||||||
static::issetInArray($data, ['id_group', 'groupId']),
|
static::issetInArray($data, ['id_group', 'groupId']),
|
||||||
|
@ -125,7 +125,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @return mixed String representing the image name (not empty) or null.
|
* @return mixed String representing the image name (not empty) or null.
|
||||||
*/
|
*/
|
||||||
private function extractBackgroundImage(array $data)
|
private static function extractBackgroundImage(array $data)
|
||||||
{
|
{
|
||||||
$backgroundImage = static::notEmptyStringOr(
|
$backgroundImage = static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['background', 'backgroundURL']),
|
static::issetInArray($data, ['background', 'backgroundURL']),
|
||||||
|
@ -143,7 +143,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @return mixed String representing the image url (not empty) or null.
|
* @return mixed String representing the image url (not empty) or null.
|
||||||
*/
|
*/
|
||||||
private function extractBackgroundUrl(array $data)
|
private static function extractBackgroundUrl(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['backgroundURL']),
|
static::issetInArray($data, ['backgroundURL']),
|
||||||
|
@ -159,7 +159,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @return mixed String representing the color (not empty) or null.
|
* @return mixed String representing the color (not empty) or null.
|
||||||
*/
|
*/
|
||||||
private function extractBackgroundColor(array $data)
|
private static function extractBackgroundColor(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::notEmptyStringOr(
|
||||||
static::issetInArray(
|
static::issetInArray(
|
||||||
|
@ -181,7 +181,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @return boolean If the item is favorite or not.
|
* @return boolean If the item is favorite or not.
|
||||||
*/
|
*/
|
||||||
private function extractFavorite(array $data): bool
|
private static function extractFavorite(array $data): bool
|
||||||
{
|
{
|
||||||
return static::parseBool(
|
return static::parseBool(
|
||||||
static::issetInArray($data, ['is_favourite', 'isFavorite'])
|
static::issetInArray($data, ['is_favourite', 'isFavorite'])
|
||||||
|
@ -383,7 +383,7 @@ final class Container extends Model
|
||||||
$class = static::getItemClass($itemType);
|
$class = static::getItemClass($itemType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\array_push($items, $class::fromDB(['id' => $itemId]));
|
array_push($items, $class::fromDB(['id' => $itemId]));
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// TODO: Log this?
|
// TODO: Log this?
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,7 +667,7 @@ class Item extends Model
|
||||||
if (isset($data['encodedHtml']) === true) {
|
if (isset($data['encodedHtml']) === true) {
|
||||||
return $data['encodedHtml'];
|
return $data['encodedHtml'];
|
||||||
} else if (isset($data['html']) === true) {
|
} else if (isset($data['html']) === true) {
|
||||||
return \base64_encode($data['html']);
|
return base64_encode($data['html']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
@ -686,6 +686,10 @@ class Item extends Model
|
||||||
*/
|
*/
|
||||||
protected static function fetchDataFromDB(array $filter): array
|
protected static function fetchDataFromDB(array $filter): array
|
||||||
{
|
{
|
||||||
|
// Load side libraries.
|
||||||
|
global $config;
|
||||||
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
|
||||||
// Due to this DB call, this function cannot be unit tested without
|
// Due to this DB call, this function cannot be unit tested without
|
||||||
// a proper mock.
|
// a proper mock.
|
||||||
$row = \db_get_row_filter('tlayout_data', $filter);
|
$row = \db_get_row_filter('tlayout_data', $filter);
|
||||||
|
@ -698,11 +702,6 @@ class Item extends Model
|
||||||
global $config;
|
global $config;
|
||||||
include_once $config['homedir'].'/include/functions_io.php';
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
|
||||||
if (\is_metaconsole()) {
|
|
||||||
\enterprise_include_once('include/functions_metaconsole.php');
|
|
||||||
\enterprise_include_once('meta/include/functions_ui_meta.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up to two levels of HTML entities.
|
// Clean up to two levels of HTML entities.
|
||||||
$row = \io_safe_output(\io_safe_output($row));
|
$row = \io_safe_output(\io_safe_output($row));
|
||||||
|
|
||||||
|
@ -712,9 +711,9 @@ class Item extends Model
|
||||||
|
|
||||||
// The linked module includes the agent data.
|
// The linked module includes the agent data.
|
||||||
if (static::$useLinkedModule === true) {
|
if (static::$useLinkedModule === true) {
|
||||||
$row = \array_merge($row, static::fetchModuleDataFromDB($row));
|
$row = array_merge($row, static::fetchModuleDataFromDB($row));
|
||||||
} else if (static::$useLinkedAgent === true) {
|
} else if (static::$useLinkedAgent === true) {
|
||||||
$row = \array_merge($row, static::fetchAgentDataFromDB($row));
|
$row = array_merge($row, static::fetchAgentDataFromDB($row));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the item link if needed.
|
// Build the item link if needed.
|
||||||
|
@ -806,6 +805,11 @@ class Item extends Model
|
||||||
*/
|
*/
|
||||||
protected static function fetchModuleDataFromDB(array $itemData): array
|
protected static function fetchModuleDataFromDB(array $itemData): array
|
||||||
{
|
{
|
||||||
|
// Load side libraries.
|
||||||
|
if (\is_metaconsole()) {
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize with the agent data.
|
// Initialize with the agent data.
|
||||||
$moduleData = static::fetchAgentDataFromDB($itemData);
|
$moduleData = static::fetchAgentDataFromDB($itemData);
|
||||||
|
|
||||||
|
@ -830,7 +834,9 @@ class Item extends Model
|
||||||
$moduleName = false;
|
$moduleName = false;
|
||||||
|
|
||||||
// Connect to node.
|
// Connect to node.
|
||||||
if (\is_metaconsole() && \metaconsole_connect(null, $metaconsoleId) !== NOERR) {
|
if (\is_metaconsole()
|
||||||
|
&& \metaconsole_connect(null, $metaconsoleId) !== NOERR
|
||||||
|
) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'error connecting to the node'
|
'error connecting to the node'
|
||||||
);
|
);
|
||||||
|
@ -874,8 +880,10 @@ class Item extends Model
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Load side libraries.
|
// Load side libraries.
|
||||||
\enterprise_include_once('include/functions_metaconsole.php');
|
if (\is_metaconsole()) {
|
||||||
\enterprise_include_once('meta/include/functions_ui_meta.php');
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
\enterprise_include_once('meta/include/functions_ui_meta.php');
|
||||||
|
}
|
||||||
|
|
||||||
$linkedVisualConsole = static::extractLinkedVisualConsole($data);
|
$linkedVisualConsole = static::extractLinkedVisualConsole($data);
|
||||||
$linkedModule = static::extractLinkedModule($data);
|
$linkedModule = static::extractLinkedModule($data);
|
||||||
|
|
Loading…
Reference in New Issue