Created
July 16, 2010 04:35
-
-
Save Majkl578/477925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Basis; | |
use Doctrine, Nette, Nette\Web\Html; | |
/** | |
* @author Štěpán Svoboda | |
* @author Michael Moravec | |
*/ | |
class DoctrineSQLPanel implements Doctrine\DBAL\Logging\SQLLogger, Nette\IDebugPanel | |
{ | |
private static $queries = array(); | |
public function logSQL($sql, array $params = NULL) | |
{ | |
self::$queries[] = $sql; | |
} | |
public function getPanel() | |
{ | |
$div = Html::el('div'); | |
$div->add(Html::el('h1')->setHtml('<strong>Doctrine</strong> (' . count(self::$queries) . ' queries)')); | |
$content = Html::el('div style="width: 500px; height: 400px; overflow: scroll;"'); | |
foreach (self::$queries as $q) { | |
$content->add(Html::el('br')); | |
$content->add(Html::el('p')->setText($q)); | |
} | |
return (string) $div->add($content); | |
} | |
public function getTab() | |
{ | |
return '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC"><strong>Doctrine</strong> (' . count(self::$queries) . ' queries)'; | |
} | |
public function getId() | |
{ | |
return 'DoctrinePanel'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//registration | |
$logger = new App\Basis\DoctrineSQLPanel; | |
Nette\Debug::addPanel($logger); | |
$config->setSQLLogger($logger); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment