Skip to content

Commit

Permalink
ConnectionPanel, Helpers: removed static access to Tracy
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 16, 2020
1 parent 67bda81 commit 27a5f9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/Bridges/DatabaseTracy/ConnectionPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand All @@ -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)
) {
Expand Down
10 changes: 6 additions & 4 deletions src/Database/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 27a5f9d

Please sign in to comment.