From 27a5f9d79faca3d8dd6c7d6a810638e46c99cd9b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 11 Dec 2020 20:48:18 +0100 Subject: [PATCH] ConnectionPanel, Helpers: removed static access to Tracy --- src/Bridges/DatabaseTracy/ConnectionPanel.php | 8 ++++++-- src/Database/Helpers.php | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Bridges/DatabaseTracy/ConnectionPanel.php b/src/Bridges/DatabaseTracy/ConnectionPanel.php index bdb3e1d5b..fc8cdff93 100644 --- a/src/Bridges/DatabaseTracy/ConnectionPanel.php +++ b/src/Bridges/DatabaseTracy/ConnectionPanel.php @@ -46,10 +46,14 @@ class ConnectionPanel implements Tracy\IBarPanel /** @var array */ private $queries = []; + /** @var Tracy\BlueScreen */ + private $blueScreen; - public function __construct(Connection $connection) + + public function __construct(Connection $connection, Tracy\BlueScreen $blueScreen) { $connection->onQuery[] = \Closure::fromCallable([$this, 'logQuery']); + $this->blueScreen = $blueScreen; } @@ -66,7 +70,7 @@ private function logQuery(Connection $connection, $result): void : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); foreach ($trace as $row) { if ( - (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) + (isset($row['file']) && is_file($row['file']) && !$this->blueScreen->isCollapsed($row['file'])) && ($row['class'] ?? '') !== self::class && !is_a($row['class'] ?? '', Connection::class, true) ) { diff --git a/src/Database/Helpers.php b/src/Database/Helpers.php index e87f00995..fa2f4667b 100644 --- a/src/Database/Helpers.php +++ b/src/Database/Helpers.php @@ -242,13 +242,15 @@ public static function loadFromFile(Connection $connection, string $file, callab public static function createDebugPanel( $connection, - bool $explain = true, - string $name = null + bool $explain, + string $name, + Tracy\Bar $bar, + Tracy\BlueScreen $blueScreen ): Nette\Bridges\DatabaseTracy\ConnectionPanel { - $panel = new Nette\Bridges\DatabaseTracy\ConnectionPanel($connection); + $panel = new Nette\Bridges\DatabaseTracy\ConnectionPanel($connection, $blueScreen); $panel->explain = $explain; $panel->name = $name; - Tracy\Debugger::getBar()->addPanel($panel); + $bar->addPanel($panel); return $panel; }