mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 21:28:02 +02:00
DibiNettePanel is compatible with Nette Framework 2.1 [Closes #97]
This commit is contained in:
@@ -47,7 +47,7 @@ class DibiNette20Extension extends Nette\Config\CompilerExtension
|
|||||||
$panel = $container->addDefinition($this->prefix('panel'))
|
$panel = $container->addDefinition($this->prefix('panel'))
|
||||||
->setClass('DibiNettePanel')
|
->setClass('DibiNettePanel')
|
||||||
->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?)', array('@self'))
|
->addSetup('Nette\Diagnostics\Debugger::$bar->addPanel(?)', array('@self'))
|
||||||
->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array(array('@self', 'renderException')));
|
->addSetup('Nette\Diagnostics\Debugger::$blueScreen->addPanel(?)', array('DibiNettePanel::renderException'));
|
||||||
|
|
||||||
$connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent')));
|
$connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent')));
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ class DibiNette21Extension extends Nette\DI\CompilerExtension
|
|||||||
$panel = $container->addDefinition($this->prefix('panel'))
|
$panel = $container->addDefinition($this->prefix('panel'))
|
||||||
->setClass('DibiNettePanel')
|
->setClass('DibiNettePanel')
|
||||||
->addSetup('Nette\Diagnostics\Debugger::getBar()->addPanel(?)', array('@self'))
|
->addSetup('Nette\Diagnostics\Debugger::getBar()->addPanel(?)', array('@self'))
|
||||||
->addSetup('Nette\Diagnostics\Debugger::getBlueScreen()->addPanel(?)', array(array('@self', 'renderException')));
|
->addSetup('Nette\Diagnostics\Debugger::getBlueScreen()->addPanel(?)', array('DibiNettePanel::renderException'));
|
||||||
|
|
||||||
$connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent')));
|
$connection->addSetup('$service->onEvent[] = ?', array(array($panel, 'logEvent')));
|
||||||
}
|
}
|
||||||
|
@@ -49,20 +49,24 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
|
|
||||||
public function register(DibiConnection $connection)
|
public function register(DibiConnection $connection)
|
||||||
{
|
{
|
||||||
static $done;
|
|
||||||
if (is_callable('Nette\Diagnostics\Debugger::enable') && !class_exists('NDebugger')) {
|
if (is_callable('Nette\Diagnostics\Debugger::enable') && !class_exists('NDebugger')) {
|
||||||
class_alias('Nette\Diagnostics\Debugger', 'NDebugger'); // PHP 5.2 code compatibility
|
class_alias('Nette\Diagnostics\Debugger', 'NDebugger'); // PHP 5.2 code compatibility
|
||||||
}
|
}
|
||||||
if (is_callable('NDebugger::enable')) {
|
if (is_callable('NDebugger::enable') && is_callable('NDebugger::getBlueScreen')) { // Nette Framework 2.1
|
||||||
NDebugger::$bar && NDebugger::$bar->addPanel($this);
|
NDebugger::getBar()->addPanel($this);
|
||||||
NDebugger::$blueScreen && !$done && NDebugger::$blueScreen->addPanel(array($this, 'renderException'), __CLASS__);
|
NDebugger::getBlueScreen()->addPanel(array(__CLASS__, 'renderException'));
|
||||||
$connection->onEvent[] = array($this, 'logEvent');
|
$connection->onEvent[] = array($this, 'logEvent');
|
||||||
} elseif (is_callable('Debugger::enable')) {
|
|
||||||
|
} elseif (is_callable('NDebugger::enable')) { // Nette Framework 2.0 (for PHP 5.3 or PHP 5.2 prefixed)
|
||||||
|
NDebugger::$bar && NDebugger::$bar->addPanel($this);
|
||||||
|
NDebugger::$blueScreen && NDebugger::$blueScreen->addPanel(array(__CLASS__, 'renderException'), __CLASS__);
|
||||||
|
$connection->onEvent[] = array($this, 'logEvent');
|
||||||
|
|
||||||
|
} elseif (is_callable('Debugger::enable') && !is_callable('Debugger::getBlueScreen')) { // Nette Framework 2.0 for PHP 5.2 non-prefixed
|
||||||
Debugger::$bar && Debugger::$bar->addPanel($this);
|
Debugger::$bar && Debugger::$bar->addPanel($this);
|
||||||
Debugger::$blueScreen && !$done && Debugger::$blueScreen->addPanel(array($this, 'renderException'), __CLASS__);
|
Debugger::$blueScreen && Debugger::$blueScreen->addPanel(array(__CLASS__, 'renderException'), __CLASS__);
|
||||||
$connection->onEvent[] = array($this, 'logEvent');
|
$connection->onEvent[] = array($this, 'logEvent');
|
||||||
}
|
}
|
||||||
$done = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
* Returns blue-screen custom tab.
|
* Returns blue-screen custom tab.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function renderException($e)
|
public static function renderException($e)
|
||||||
{
|
{
|
||||||
if ($e instanceof DibiException && $e->getSql()) {
|
if ($e instanceof DibiException && $e->getSql()) {
|
||||||
return array(
|
return array(
|
||||||
@@ -140,7 +144,7 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
if ($explain) {
|
if ($explain) {
|
||||||
static $counter;
|
static $counter;
|
||||||
$counter++;
|
$counter++;
|
||||||
$s .= "<br /><a href='#nette-debug-DibiProfiler-row-$counter' class='nette-toggle-collapsed'>explain</a>";
|
$s .= "<br /><a href='#nette-debug-DibiProfiler-row-$counter' class='nette-toggler nette-toggle-collapsed' rel='#nette-debug-DibiProfiler-row-$counter'>explain</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= '</td><td class="nette-DibiProfiler-sql">' . dibi::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, TRUE);
|
$s .= '</td><td class="nette-DibiProfiler-sql">' . dibi::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, TRUE);
|
||||||
|
Reference in New Issue
Block a user