Skip to content

Commit

Permalink
DIExtension: detects Tracy by presence of service @tracy\Bar [Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 25, 2020
1 parent ad1d29c commit c8743ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/DI/Extensions/DIExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] */
Expand All @@ -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);
}


Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit c8743ea

Please sign in to comment.