Skip to content

Commit

Permalink
used setFactory() instead of misused setClass()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 24, 2017
1 parent c5a11d2 commit f69175c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationDI/ApplicationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function loadConfiguration()
: UI\Presenter::INVALID_LINK_WARNING;

$application = $builder->addDefinition($this->prefix('application'))
->setClass(Nette\Application\Application::class)
->setFactory(Nette\Application\Application::class)
->addSetup('$catchExceptions', [$config['catchExceptions']])
->addSetup('$errorPresenter', [$config['errorPresenter']]);

Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/ApplicationDI/LatteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function loadConfiguration()
$builder = $this->getContainerBuilder();

$builder->addDefinition($this->prefix('latteFactory'))
->setClass(Latte\Engine::class)
->setFactory(Latte\Engine::class)
->addSetup('setTempDirectory', [$this->tempDir])
->addSetup('setAutoRefresh', [$this->debugMode])
->addSetup('setContentType', [$config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML])
Expand Down
4 changes: 2 additions & 2 deletions tests/Bridges.DI/ApplicationExtension.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ test(function () {
$compiler->addExtension('application', new ApplicationExtension(false));

$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myRouter')->setFactory(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);
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);

$code = $compiler->setClassName('Container1')->compile();
eval($code);
Expand Down
4 changes: 2 additions & 2 deletions tests/Bridges.DI/ApplicationExtension.invalidLink.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function createCompiler($config)
$compiler = new DI\Compiler;
$compiler->loadConfig(Tester\FileMock::create($config, 'neon'));
$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myRouter')->setFactory(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);
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);
return $compiler;
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Bridges.DI/ApplicationExtension.scan.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ test(function () {
$compiler->addExtension('application', new ApplicationExtension);

$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myRouter')->setFactory(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);
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);
$code = $compiler->setClassName('Container1')->compile();
eval($code);

Expand All @@ -37,9 +37,9 @@ test(function () {
$compiler->addExtension('application', new ApplicationExtension);

$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myRouter')->setFactory(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);
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);
$code = $compiler->addConfig([
'application' => [
'scanDirs' => [__DIR__ . '/files'],
Expand All @@ -60,9 +60,9 @@ test(function () {
$compiler->addExtension('application', new ApplicationExtension(false, [__DIR__ . '/files']));

$builder = $compiler->getContainerBuilder();
$builder->addDefinition('myRouter')->setClass(Nette\Application\Routers\SimpleRouter::class);
$builder->addDefinition('myRouter')->setFactory(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);
$builder->addDefinition('myHttpResponse')->setFactory(Nette\Http\Response::class);
$loader = new DI\Config\Loader;
$config = $loader->load(Tester\FileMock::create('
services:
Expand Down

0 comments on commit f69175c

Please sign in to comment.