From 9c31b24407623437c1e1345cc2bd4e210b290135 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 21 Dec 2022 14:11:27 +0100 Subject: [PATCH] Latte: uses TracyExtension --- composer.json | 2 +- src/Bridges/ApplicationDI/LatteExtension.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b90b61020..aca070708 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "nette/di": "<3.0.7", "nette/forms": "<3.0", "nette/schema": "<1.2", - "latte/latte": "<2.7.1 || >=3.1 || =3.0.0", + "latte/latte": "<2.7.1 || >=3.0.0 <3.0.5 || >=3.1", "tracy/tracy": "<2.5" }, "autoload": { diff --git a/src/Bridges/ApplicationDI/LatteExtension.php b/src/Bridges/ApplicationDI/LatteExtension.php index 6a69ba8c0..c50846f36 100644 --- a/src/Bridges/ApplicationDI/LatteExtension.php +++ b/src/Bridges/ApplicationDI/LatteExtension.php @@ -117,10 +117,12 @@ public static function initLattePanel( $factory->onCreate[] = function (ApplicationLatte\Template $template) use ($bar, $all) { $control = $template->getLatte()->getProviders()['uiControl'] ?? null; if ($all || $control instanceof Nette\Application\UI\Presenter) { - $bar->addPanel(new Latte\Bridges\Tracy\LattePanel( - $template->getLatte(), - $all && $control ? (new \ReflectionObject($control))->getShortName() : '' - )); + $name = $all && $control ? (new \ReflectionObject($control))->getShortName() : ''; + if (version_compare(Latte\Engine::VERSION, '3', '<')) { + $bar->addPanel(new Latte\Bridges\Tracy\LattePanel($template->getLatte(), $name)); + } else { + $template->getLatte()->addExtension(new Latte\Bridges\Tracy\TracyExtension($name)); + } } }; }