ImportsourceHookTable: show malformed data...
...plus some namespacing/cleanup
This commit is contained in:
parent
1027084f04
commit
8c04de0a14
|
@ -8,7 +8,7 @@ class Json
|
|||
{
|
||||
public static function encode($mixed, $flags = null)
|
||||
{
|
||||
$result = json_encode($mixed, $flags);
|
||||
$result = \json_encode($mixed, $flags);
|
||||
|
||||
if ($result === false && json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw JsonEncodeException::forLastJsonError();
|
||||
|
@ -19,7 +19,7 @@ class Json
|
|||
|
||||
public static function decode($string)
|
||||
{
|
||||
$result = json_decode($string);
|
||||
$result = \json_decode($string);
|
||||
|
||||
if ($result === null && json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw JsonEncodeException::forLastJsonError();
|
||||
|
|
|
@ -9,24 +9,24 @@ class JsonException extends IcingaException
|
|||
public static function forLastJsonError($msg = null)
|
||||
{
|
||||
if ($msg === null) {
|
||||
return new static(static::getJsonErrorMessage(json_last_error()));
|
||||
return new static(static::getJsonErrorMessage(\json_last_error()));
|
||||
} else {
|
||||
$args = func_get_args();
|
||||
$args[0] = $msg . ': ' . static::getJsonErrorMessage(json_last_error());
|
||||
return call_user_func_array('static::__construct', $args);
|
||||
$args = \func_get_args();
|
||||
$args[0] = $msg . ': ' . static::getJsonErrorMessage(\json_last_error());
|
||||
return \call_user_func_array('static::__construct', $args);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getJsonErrorMessage($code)
|
||||
{
|
||||
$map = [
|
||||
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
|
||||
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
|
||||
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
|
||||
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
|
||||
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
|
||||
JSON_ERROR_SYNTAX => 'Syntax error',
|
||||
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
|
||||
JSON_ERROR_SYNTAX => 'JSON Syntax error',
|
||||
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
|
||||
];
|
||||
if (array_key_exists($code, $map)) {
|
||||
if (\array_key_exists($code, $map)) {
|
||||
return $map[$code];
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class JsonException extends IcingaException
|
|||
JSON_ERROR_INF_OR_NAN => 'One or more NAN or INF values in the value to be encoded',
|
||||
JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given',
|
||||
];
|
||||
if (array_key_exists($code, $map)) {
|
||||
if (\array_key_exists($code, $map)) {
|
||||
return $map[$code];
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class JsonException extends IcingaException
|
|||
JSON_ERROR_UTF16 => 'Malformed UTF-16 characters, possibly incorrectly encoded',
|
||||
];
|
||||
|
||||
if (array_key_exists($code, $map)) {
|
||||
if (\array_key_exists($code, $map)) {
|
||||
return $map[$code];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,12 +65,15 @@ class ImportsourceHookTable extends SimpleQueryBasedTable
|
|||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
if (\is_array($row)) {
|
||||
$row = (object) $row;
|
||||
}
|
||||
$tr = $this::tr();
|
||||
|
||||
foreach ($this->getColumnsToBeRendered() as $column) {
|
||||
$td = $this::td();
|
||||
if (property_exists($row, $column)) {
|
||||
if (is_string($row->$column) || $row->$column instanceof ValidHtml) {
|
||||
if (\property_exists($row, $column)) {
|
||||
if (\is_string($row->$column) || $row->$column instanceof ValidHtml) {
|
||||
$td->setContent($row->$column);
|
||||
} else {
|
||||
$html = Html::tag('pre', null, PlainObjectRenderer::render($row->$column));
|
||||
|
|
Loading…
Reference in New Issue