From 20a93cadd76dfb10d99100c410c602e75f8b5f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mor=C3=A1vek=20=5BXificurk=5D?= Date: Wed, 3 Feb 2016 15:30:33 +0100 Subject: [PATCH] ApplicationExtension: do not initialize RoutingPanel if Tracy is not installed --- src/Bridges/ApplicationDI/ApplicationExtension.php | 4 +++- src/Bridges/ApplicationDI/RoutingExtension.php | 4 +++- tests/Bridges.DI/ApplicationExtension.basic.phpt | 4 +--- tests/Bridges.DI/ApplicationExtension.invalidLink.phpt | 4 ---- tests/Bridges.DI/ApplicationExtension.scan.phpt | 8 +------- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index 704ea334c..d511cbde1 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -9,6 +9,7 @@ use Nette; use Nette\Application\UI; +use Tracy; use Composer\Autoload\ClassLoader; @@ -18,7 +19,7 @@ class ApplicationExtension extends Nette\DI\CompilerExtension { public $defaults = [ - 'debugger' => TRUE, + 'debugger' => NULL, 'errorPresenter' => 'Nette:Error', 'catchExceptions' => NULL, 'mapping' => NULL, @@ -40,6 +41,7 @@ class ApplicationExtension extends Nette\DI\CompilerExtension public function __construct($debugMode = FALSE, array $scanDirs = NULL, $tempDir = NULL) { + $this->defaults['debugger'] = class_exists(Tracy\IBarPanel::class); $this->defaults['scanDirs'] = (array) $scanDirs; $this->defaults['scanComposer'] = class_exists(ClassLoader::class); $this->defaults['catchExceptions'] = !$debugMode; diff --git a/src/Bridges/ApplicationDI/RoutingExtension.php b/src/Bridges/ApplicationDI/RoutingExtension.php index db79def64..c8b6c0b18 100644 --- a/src/Bridges/ApplicationDI/RoutingExtension.php +++ b/src/Bridges/ApplicationDI/RoutingExtension.php @@ -8,6 +8,7 @@ namespace Nette\Bridges\ApplicationDI; use Nette; +use Tracy; /** @@ -16,7 +17,7 @@ class RoutingExtension extends Nette\DI\CompilerExtension { public $defaults = [ - 'debugger' => TRUE, + 'debugger' => NULL, 'routes' => [], // of [mask => action] 'cache' => FALSE, ]; @@ -27,6 +28,7 @@ class RoutingExtension extends Nette\DI\CompilerExtension public function __construct($debugMode = FALSE) { + $this->defaults['debugger'] = class_exists(Tracy\IBarPanel::class); $this->debugMode = $debugMode; } diff --git a/tests/Bridges.DI/ApplicationExtension.basic.phpt b/tests/Bridges.DI/ApplicationExtension.basic.phpt index 730ca853b..577b8b4f2 100644 --- a/tests/Bridges.DI/ApplicationExtension.basic.phpt +++ b/tests/Bridges.DI/ApplicationExtension.basic.phpt @@ -21,9 +21,7 @@ test(function () { $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); - $code = $compiler->compile([ - 'application' => ['debugger' => FALSE], - ], 'Container1'); + $code = $compiler->compile([], 'Container1'); eval($code); $container = new Container1; diff --git a/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt b/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt index e4184464e..19658e865 100644 --- a/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt +++ b/tests/Bridges.DI/ApplicationExtension.invalidLink.phpt @@ -29,7 +29,6 @@ function createCompiler($config) test(function () { $compiler = createCompiler(' application: - debugger: no silentLinks: yes services: @@ -50,7 +49,6 @@ test(function () { test(function () { $compiler = createCompiler(' application: - debugger: no silentLinks: no services: @@ -71,7 +69,6 @@ test(function () { test(function () { $compiler = createCompiler(' application: - debugger: no silentLinks: yes services: @@ -92,7 +89,6 @@ test(function () { test(function () { $compiler = createCompiler(' application: - debugger: no silentLinks: no services: diff --git a/tests/Bridges.DI/ApplicationExtension.scan.phpt b/tests/Bridges.DI/ApplicationExtension.scan.phpt index 13f6f4be5..b30af77bc 100644 --- a/tests/Bridges.DI/ApplicationExtension.scan.phpt +++ b/tests/Bridges.DI/ApplicationExtension.scan.phpt @@ -21,9 +21,7 @@ test(function () { $builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class); $builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]); $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); - $code = $compiler->compile([ - 'application' => ['debugger' => FALSE], - ], 'Container1'); + $code = $compiler->compile([], 'Container1'); eval($code); $container = new Container1; @@ -45,7 +43,6 @@ test(function () { $code = $compiler->compile([ 'application' => [ 'scanDirs' => [__DIR__ . '/files'], - 'debugger' => FALSE, ], ], 'Container2'); eval($code); @@ -68,9 +65,6 @@ test(function () { $builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class); $loader = new DI\Config\Loader; $config = $loader->load(Tester\FileMock::create(' - application: - debugger: no - services: - factory: Presenter1