Reputation: 497
Adminer's Pretty JSON Columns plugin code here
version: '3.7'
services:
adminer:
image: 'adminer:latest'
restart: always
user: root
ports:
- '8080:8080'
volumes:
- ./plugins/pretty-json-column.php:/var/www/html/plugins-enabled/pretty-json-column.php
environment:
- PUID=0
- PGID=0
- 'ADMINER_DESIGN=dracula'
- 'ADMINER_PLUGINS=dump-json dump-xml dump-zip'
<?php
require_once('plugins/pretty-json-column.php');
/**
Set json text??????
@param array (I think???)
**/
return new AdminerPrettyJsonColumn(
$adminer = ???
);
I tried making $adminer = json_encode($value, JSON_PRETTY_PRINT)
, but when I tested it in Adminer, I got the error
**Fatal error**: Uncaught Error: Call to a member function _callParent() on string in /var/www/html/plugins/pretty-json-column.php:38 Stack trace: #0 /var/www/html/plugins/plugin.php(47): AdminerPrettyJsonColumn->processInput(Array, '{"glossary":{"t...', '') #1 /var/www/html/plugins/plugin.php(355): AdminerPlugin->_applyPlugin('processInput', Array) #2 /var/www/html/adminer.php(124): AdminerPlugin->processInput(Array, '{\r\n "glossar...', '') #3 /var/www/html/adminer.php(1597): process_input(Array) #4 /var/www/html/index.php(42): require('/var/www/html/a...') #5 {main} thrown in **/var/www/html/plugins/pretty-json-column.php** on line **38**
I'm not sure how to read the plugin and the documentation wasn't helpful.
My sample JSON data (courtesy of https://json.org/example.html):
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
Upvotes: 1
Views: 386
Reputation: 383
I was able to accomplish the desired result with the following modified version:
<?php
require_once('plugins/pretty-json-column.php');
$adminer = new AdminerPlugin([]);
return new AdminerPrettyJsonColumn(
$adminer
);
Upvotes: 0
Reputation: 1
try this
function adminer_object()
{
$adminer = new AdminerPlugin([]);
$plugins = [
new AdminerPrettyJsonColumn($adminer),
];
$adminer->plugins = $plugins;
return $adminer;
}
Upvotes: 0