public function testGenMarkdownRow() { $this->init(); $panel = new \histou\grafana\TextPanel('', 1); $panel->setMode(\histou\grafana\TextPanel::MARKDOWN); $panel->setContent("foo"); $row = new \histou\grafana\Row("bar"); $row->addPanel($panel); $this->assertEquals($row, \histou\Debug::genRow("foo", \histou\grafana\TextPanel::MARKDOWN, "bar")); }
/** This function will print its input and exit with the given returncode. @param object $data This object will be converted to json. @param int $returnCode The returncode the programm will exit. @return null. **/ public static function returnData($data, $returnCode = 0) { if (is_object($data) && is_subclass_of($data, 'histou\\grafana\\dashboard\\Dashboard')) { if (\histou\Debug::isEnable()) { //$data->addRow(\histou\Debug::genMarkdownRow(\histou\Debug::getLogAsMarkdown(), 'Debug')); //for markdown $data->addRow(\histou\Debug::genRow(\histou\Debug::getLog())); } $data = $data->toArray(); $json = json_encode($data); } elseif (is_string($data)) { $json = $data; } else { echo '<pre>'; print_r("Don't know what to do with this type: " . gettype($data)); var_dump($data); echo '</pre>'; } if (isset($json)) { if (isset($_GET["callback"]) && !empty($_GET["callback"])) { header('content-type: application/json; charset=utf-8'); echo "{$_GET['callback']}({$json})"; } else { echo "<pre>"; print_r($data); echo "<br>"; print_r($returnCode); echo "<br>"; print_r($json); echo "<br>"; echo "</pre>"; } } }