Skip to content

Commit 20a93ca

Browse files
xificurkdg
authored andcommitted
ApplicationExtension: do not initialize RoutingPanel if Tracy is not installed
1 parent 4e87d71 commit 20a93ca

5 files changed

+8
-16
lines changed

src/Bridges/ApplicationDI/ApplicationExtension.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Nette;
1111
use Nette\Application\UI;
12+
use Tracy;
1213
use Composer\Autoload\ClassLoader;
1314

1415

@@ -18,7 +19,7 @@
1819
class ApplicationExtension extends Nette\DI\CompilerExtension
1920
{
2021
public $defaults = [
21-
'debugger' => TRUE,
22+
'debugger' => NULL,
2223
'errorPresenter' => 'Nette:Error',
2324
'catchExceptions' => NULL,
2425
'mapping' => NULL,
@@ -40,6 +41,7 @@ class ApplicationExtension extends Nette\DI\CompilerExtension
4041

4142
public function __construct($debugMode = FALSE, array $scanDirs = NULL, $tempDir = NULL)
4243
{
44+
$this->defaults['debugger'] = class_exists(Tracy\IBarPanel::class);
4345
$this->defaults['scanDirs'] = (array) $scanDirs;
4446
$this->defaults['scanComposer'] = class_exists(ClassLoader::class);
4547
$this->defaults['catchExceptions'] = !$debugMode;

src/Bridges/ApplicationDI/RoutingExtension.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Nette\Bridges\ApplicationDI;
99

1010
use Nette;
11+
use Tracy;
1112

1213

1314
/**
@@ -16,7 +17,7 @@
1617
class RoutingExtension extends Nette\DI\CompilerExtension
1718
{
1819
public $defaults = [
19-
'debugger' => TRUE,
20+
'debugger' => NULL,
2021
'routes' => [], // of [mask => action]
2122
'cache' => FALSE,
2223
];
@@ -27,6 +28,7 @@ class RoutingExtension extends Nette\DI\CompilerExtension
2728

2829
public function __construct($debugMode = FALSE)
2930
{
31+
$this->defaults['debugger'] = class_exists(Tracy\IBarPanel::class);
3032
$this->debugMode = $debugMode;
3133
}
3234

tests/Bridges.DI/ApplicationExtension.basic.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ test(function () {
2121
$builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]);
2222
$builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class);
2323

24-
$code = $compiler->compile([
25-
'application' => ['debugger' => FALSE],
26-
], 'Container1');
24+
$code = $compiler->compile([], 'Container1');
2725
eval($code);
2826

2927
$container = new Container1;

tests/Bridges.DI/ApplicationExtension.invalidLink.phpt

-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function createCompiler($config)
2929
test(function () {
3030
$compiler = createCompiler('
3131
application:
32-
debugger: no
3332
silentLinks: yes
3433
3534
services:
@@ -50,7 +49,6 @@ test(function () {
5049
test(function () {
5150
$compiler = createCompiler('
5251
application:
53-
debugger: no
5452
silentLinks: no
5553
5654
services:
@@ -71,7 +69,6 @@ test(function () {
7169
test(function () {
7270
$compiler = createCompiler('
7371
application:
74-
debugger: no
7572
silentLinks: yes
7673
7774
services:
@@ -92,7 +89,6 @@ test(function () {
9289
test(function () {
9390
$compiler = createCompiler('
9491
application:
95-
debugger: no
9692
silentLinks: no
9793
9894
services:

tests/Bridges.DI/ApplicationExtension.scan.phpt

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ test(function () {
2121
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
2222
$builder->addDefinition('myHttpRequest')->setFactory(Nette\Http\Request::class, [new DI\Statement(Nette\Http\UrlScript::class)]);
2323
$builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class);
24-
$code = $compiler->compile([
25-
'application' => ['debugger' => FALSE],
26-
], 'Container1');
24+
$code = $compiler->compile([], 'Container1');
2725
eval($code);
2826

2927
$container = new Container1;
@@ -45,7 +43,6 @@ test(function () {
4543
$code = $compiler->compile([
4644
'application' => [
4745
'scanDirs' => [__DIR__ . '/files'],
48-
'debugger' => FALSE,
4946
],
5047
], 'Container2');
5148
eval($code);
@@ -68,9 +65,6 @@ test(function () {
6865
$builder->addDefinition('myHttpResponse')->setClass(Nette\Http\Response::class);
6966
$loader = new DI\Config\Loader;
7067
$config = $loader->load(Tester\FileMock::create('
71-
application:
72-
debugger: no
73-
7468
services:
7569
-
7670
factory: Presenter1

0 commit comments

Comments
 (0)