From c8743ea3152353dec21559f3d3d0dea99da631c8 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 6 Oct 2020 16:56:17 +0200 Subject: [PATCH] DIExtension: detects Tracy by presence of service @Tracy\Bar [Closes #245] --- src/DI/Extensions/DIExtension.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DI/Extensions/DIExtension.php b/src/DI/Extensions/DIExtension.php index 3171e9d88..9f0e2ab5d 100644 --- a/src/DI/Extensions/DIExtension.php +++ b/src/DI/Extensions/DIExtension.php @@ -36,7 +36,7 @@ public function __construct(bool $debugMode = false) $this->time = microtime(true); $this->config = new class { - /** @var bool */ + /** @var ?bool */ public $debugger; /** @var string[] */ @@ -58,7 +58,6 @@ public function __construct(bool $debugMode = false) /** @var string[]|bool|null */ public $types = true; }; - $this->config->debugger = interface_exists(\Tracy\IBarPanel::class); } @@ -86,7 +85,10 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) $this->restrictTags($class); $this->restrictTypes($class); - if ($this->debugMode && $this->config->debugger) { + if ( + $this->debugMode && + ($this->config->debugger ?? $this->getContainerBuilder()->getByType(\Tracy\Bar::class)) + ) { $this->enableTracyIntegration(); }