Skip to content

Commit e2b4384

Browse files
committed
small refactoring
1 parent a7049d1 commit e2b4384

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/Application/UI/Presenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ protected function getGlobalState($forClass = NULL)
11771177
}
11781178
if ($since !== $sinces[$key]) {
11791179
$since = $sinces[$key];
1180-
$ok = $since && (is_subclass_of($forClass, $since) || $forClass === $since);
1180+
$ok = $since && is_a($forClass, $since, TRUE);
11811181
}
11821182
if (!$ok) {
11831183
unset($state[$key]);

src/Bridges/ApplicationDI/ApplicationExtension.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public function __construct($debugMode = FALSE, array $scanDirs = NULL, $tempDir
5353
public function loadConfiguration()
5454
{
5555
$config = $this->validateConfig($this->defaults);
56-
$container = $this->getContainerBuilder();
57-
$container->addExcludedClasses([UI\Control::class]);
56+
$builder = $this->getContainerBuilder();
57+
$builder->addExcludedClasses([UI\Control::class]);
5858

5959
$this->invalidLinkMode = $this->debugMode
6060
? UI\Presenter::INVALID_LINK_TEXTUAL | ($config['silentLinks'] ? 0 : UI\Presenter::INVALID_LINK_WARNING)
6161
: UI\Presenter::INVALID_LINK_WARNING;
6262

63-
$application = $container->addDefinition($this->prefix('application'))
63+
$application = $builder->addDefinition($this->prefix('application'))
6464
->setClass(Nette\Application\Application::class)
6565
->addSetup('$catchExceptions', [$config['catchExceptions']])
6666
->addSetup('$errorPresenter', [$config['errorPresenter']]);
@@ -70,7 +70,7 @@ public function loadConfiguration()
7070
}
7171

7272
$touch = $this->debugMode && $config['scanDirs'] ? $this->tempFile : NULL;
73-
$presenterFactory = $container->addDefinition($this->prefix('presenterFactory'))
73+
$presenterFactory = $builder->addDefinition($this->prefix('presenterFactory'))
7474
->setClass(Nette\Application\IPresenterFactory::class)
7575
->setFactory(Nette\Application\PresenterFactory::class, [new Nette\DI\Statement(
7676
Nette\Bridges\ApplicationDI\PresenterFactoryCallback::class, [1 => $this->invalidLinkMode, $touch]
@@ -80,31 +80,31 @@ public function loadConfiguration()
8080
$presenterFactory->addSetup('setMapping', [$config['mapping']]);
8181
}
8282

83-
$container->addDefinition($this->prefix('linkGenerator'))
83+
$builder->addDefinition($this->prefix('linkGenerator'))
8484
->setFactory(Nette\Application\LinkGenerator::class, [
8585
1 => new Nette\DI\Statement('@Nette\Http\IRequest::getUrl'),
8686
]);
8787

8888
if ($this->name === 'application') {
89-
$container->addAlias('application', $this->prefix('application'));
90-
$container->addAlias('nette.presenterFactory', $this->prefix('presenterFactory'));
89+
$builder->addAlias('application', $this->prefix('application'));
90+
$builder->addAlias('nette.presenterFactory', $this->prefix('presenterFactory'));
9191
}
9292
}
9393

9494

9595
public function beforeCompile()
9696
{
97-
$container = $this->getContainerBuilder();
97+
$builder = $this->getContainerBuilder();
9898
$all = [];
9999

100-
foreach ($container->findByType(Nette\Application\IPresenter::class) as $def) {
100+
foreach ($builder->findByType(Nette\Application\IPresenter::class) as $def) {
101101
$all[$def->getClass()] = $def;
102102
}
103103

104104
$counter = 0;
105105
foreach ($this->findPresenters() as $class) {
106106
if (empty($all[$class])) {
107-
$all[$class] = $container->addDefinition($this->prefix(++$counter))->setClass($class);
107+
$all[$class] = $builder->addDefinition($this->prefix(++$counter))->setClass($class);
108108
}
109109
}
110110

src/Bridges/ApplicationDI/LatteExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ public function loadConfiguration()
4242
}
4343

4444
$config = $this->validateConfig($this->defaults);
45-
$container = $this->getContainerBuilder();
45+
$builder = $this->getContainerBuilder();
4646

47-
$container->addDefinition($this->prefix('latteFactory'))
47+
$builder->addDefinition($this->prefix('latteFactory'))
4848
->setClass(Latte\Engine::class)
4949
->addSetup('setTempDirectory', [$this->tempDir])
5050
->addSetup('setAutoRefresh', [$this->debugMode])
5151
->addSetup('setContentType', [$config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML])
5252
->addSetup('Nette\Utils\Html::$xhtml = ?', [(bool) $config['xhtml']])
5353
->setImplement(Nette\Bridges\ApplicationLatte\ILatteFactory::class);
5454

55-
$container->addDefinition($this->prefix('templateFactory'))
55+
$builder->addDefinition($this->prefix('templateFactory'))
5656
->setClass(Nette\Application\UI\ITemplateFactory::class)
5757
->setFactory(Nette\Bridges\ApplicationLatte\TemplateFactory::class);
5858

@@ -64,8 +64,8 @@ public function loadConfiguration()
6464
}
6565

6666
if ($this->name === 'latte') {
67-
$container->addAlias('nette.latteFactory', $this->prefix('latteFactory'));
68-
$container->addAlias('nette.templateFactory', $this->prefix('templateFactory'));
67+
$builder->addAlias('nette.latteFactory', $this->prefix('latteFactory'));
68+
$builder->addAlias('nette.templateFactory', $this->prefix('templateFactory'));
6969
}
7070
}
7171

@@ -76,8 +76,8 @@ public function loadConfiguration()
7676
*/
7777
public function addMacro(callable $macro)
7878
{
79-
$container = $this->getContainerBuilder();
80-
$container->getDefinition($this->prefix('latteFactory'))
79+
$builder = $this->getContainerBuilder();
80+
$builder->getDefinition($this->prefix('latteFactory'))
8181
->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']);
8282
}
8383

src/Bridges/ApplicationDI/RoutingExtension.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function __construct($debugMode = FALSE)
3636
public function loadConfiguration()
3737
{
3838
$config = $this->validateConfig($this->defaults);
39-
$container = $this->getContainerBuilder();
39+
$builder = $this->getContainerBuilder();
4040

41-
$router = $container->addDefinition($this->prefix('router'))
41+
$router = $builder->addDefinition($this->prefix('router'))
4242
->setClass(Nette\Application\IRouter::class)
4343
->setFactory(Nette\Application\Routers\RouteList::class);
4444

@@ -47,17 +47,17 @@ public function loadConfiguration()
4747
}
4848

4949
if ($this->name === 'routing') {
50-
$container->addAlias('router', $this->prefix('router'));
50+
$builder->addAlias('router', $this->prefix('router'));
5151
}
5252
}
5353

5454

5555
public function beforeCompile()
5656
{
57-
$container = $this->getContainerBuilder();
57+
$builder = $this->getContainerBuilder();
5858

59-
if ($this->debugMode && $this->config['debugger'] && $application = $container->getByType(Nette\Application\Application::class)) {
60-
$container->getDefinition($application)->addSetup('@Tracy\Bar::addPanel', [
59+
if ($this->debugMode && $this->config['debugger'] && $application = $builder->getByType(Nette\Application\Application::class)) {
60+
$builder->getDefinition($application)->addSetup('@Tracy\Bar::addPanel', [
6161
new Nette\DI\Statement(Nette\Bridges\ApplicationTracy\RoutingPanel::class),
6262
]);
6363
}

0 commit comments

Comments
 (0)