Skip to content

Commit

Permalink
ApplicationExtension: do not initialize RoutingPanel if Tracy is not …
Browse files Browse the repository at this point in the history
…installed
  • Loading branch information
xificurk authored and dg committed Feb 8, 2016
1 parent 5eb2495 commit 08cbdeb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Nette;
use Nette\Application\UI;
use Tracy;
use Composer\Autoload\ClassLoader;


Expand All @@ -18,7 +19,7 @@
class ApplicationExtension extends Nette\DI\CompilerExtension
{
public $defaults = [
'debugger' => TRUE,
'debugger' => NULL,
'errorPresenter' => 'Nette:Error',
'catchExceptions' => NULL,
'mapping' => NULL,
Expand All @@ -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 comment has been minimized.

Copy link
@mrtnzlml

mrtnzlml Feb 9, 2016

Contributor

class_exists doesn't return TRUE for interfaces. Did you mean interface_exists? cc @xificurk

This comment has been minimized.

Copy link
@xificurk

xificurk Feb 9, 2016

Author Contributor

@mrtnzlml yes... good catch!

$this->defaults['scanDirs'] = (array) $scanDirs;
$this->defaults['scanComposer'] = class_exists(ClassLoader::class);
$this->defaults['catchExceptions'] = !$debugMode;
Expand Down
4 changes: 3 additions & 1 deletion src/Bridges/ApplicationDI/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Nette\Bridges\ApplicationDI;

use Nette;
use Tracy;


/**
Expand All @@ -16,7 +17,7 @@
class RoutingExtension extends Nette\DI\CompilerExtension
{
public $defaults = [
'debugger' => TRUE,
'debugger' => NULL,
'routes' => [], // of [mask => action]
'cache' => FALSE,
];
Expand All @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions tests/Bridges.DI/ApplicationExtension.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions tests/Bridges.DI/ApplicationExtension.invalidLink.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function createCompiler($config)
test(function () {
$compiler = createCompiler('
application:
debugger: no
silentLinks: yes
services:
Expand All @@ -50,7 +49,6 @@ test(function () {
test(function () {
$compiler = createCompiler('
application:
debugger: no
silentLinks: no
services:
Expand All @@ -71,7 +69,6 @@ test(function () {
test(function () {
$compiler = createCompiler('
application:
debugger: no
silentLinks: yes
services:
Expand All @@ -92,7 +89,6 @@ test(function () {
test(function () {
$compiler = createCompiler('
application:
debugger: no
silentLinks: no
services:
Expand Down
8 changes: 1 addition & 7 deletions tests/Bridges.DI/ApplicationExtension.scan.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +43,6 @@ test(function () {
$code = $compiler->compile([
'application' => [
'scanDirs' => [__DIR__ . '/files'],
'debugger' => FALSE,
],
], 'Container2');
eval($code);
Expand All @@ -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
Expand Down

0 comments on commit 08cbdeb

Please sign in to comment.