1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-03-15 11:50:01 +01:00

Small changes & prevent exception

This commit is contained in:
GuimDev 2013-12-26 12:24:08 +01:00
parent db00362d78
commit a3c18c1130

View File

@ -23,15 +23,17 @@ class JavascriptRenderer
const INITIALIZE_CONTROLS = 4;
const REPLACEABLE_TAG = "{--DEBUGBAR_OB_START_REPLACE_ME--}";
protected $debugBar;
protected $baseUrl;
protected $basePath;
protected $cssVendors = array('vendor/font-awesome/css/font-awesome.min.css');
protected $cssVendors = array('vendor/font-awesome/css/font-awesome.css');
protected $jsVendors = array('vendor/jquery/jquery.min.js');
protected $jsVendors = array('vendor/jquery-1.8.3.min.js');
protected $includeVendors = true;
@ -647,28 +649,36 @@ class JavascriptRenderer
/**
* Register shutdown to display the debug bar
*
* @param boolean $here Set position of HTML. True if is to current position or false for end file.
* @param boolean $here Set position of HTML. True if is to current position or false for end file
* @param boolean $initialize Whether to render the de bug bar initialization code
* @return string "{--DEBUGBAR_OB_START_REPLACE_ME--}"
* @return string Return "{--DEBUGBAR_OB_START_REPLACE_ME--}" or return an empty string if $here == false
*/
public function register_render($here = true, $initialize = true, $renderStackedData = true) {
register_shutdown_function(array($this, "register_shutdown"), $here, $initialize, $renderStackedData);
public function renderOnShutdown($here = true, $initialize = true, $renderStackedData = true) {
register_shutdown_function(array($this, "replaceTagInBuffer"), $here, $initialize, $renderStackedData);
if ($here) {
return "{--DEBUGBAR_OB_START_REPLACE_ME--}";
if (ob_get_level() === 0) {
ob_start();
}
return ($here) ? self::REPLACEABLE_TAG : "";
}
/**
* Is callback function for register_shutdown_function(...)
*
* @param boolean $here Set position of HTML. True if is to current position or false for end file.
* @param boolean $here Set position of HTML. True if is to current position or false for end file
* @param boolean $initialize Whether to render the de bug bar initialization code
*/
public function register_shutdown($here = true, $initialize = true, $renderStackedData = true) {
public function replaceTagInBuffer($here = true, $initialize = true, $renderStackedData = true) {
$render = $this->render($initialize, $renderStackedData);
echo ($here) ? str_replace("{--DEBUGBAR_OB_START_REPLACE_ME--}", $render, ob_get_clean()) : $render;
$current = ($here && ob_get_level() > 0) ? ob_get_clean() : self::REPLACEABLE_TAG;
echo str_replace(self::REPLACEABLE_TAG, $render, $current, $count);
if ($count === 0) {
echo $render;
}
}
/**