Skip to content

Commit 7a66c75

Browse files
committed
LatteExtension: Html::$xhtml is set when service is created
1 parent be88047 commit 7a66c75

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/Bridges/ApplicationDI/LatteExtension.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class LatteExtension extends Nette\DI\CompilerExtension
2424
'macros' => array(),
2525
);
2626

27-
/** @var bool */
28-
private $xhtml;
29-
3027
/** @var bool */
3128
private $debugMode;
3229

@@ -61,14 +58,14 @@ public function loadConfiguration()
6158
}
6259

6360
$this->validate($config, $this->defaults, $this->name);
64-
$this->xhtml = $config['xhtml'];
6561
$container = $this->getContainerBuilder();
6662

6763
$latteFactory = $container->addDefinition('nette.latteFactory')
6864
->setClass('Latte\Engine')
6965
->addSetup('setTempDirectory', array($this->tempDir))
7066
->addSetup('setAutoRefresh', array($this->debugMode))
7167
->addSetup('setContentType', array($config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML))
68+
->addSetup('Nette\Utils\Html::$xhtml = ?;', array((bool) $config['xhtml']))
7269
->setImplement('Nette\Bridges\ApplicationLatte\ILatteFactory');
7370

7471
$container->addDefinition('nette.templateFactory')
@@ -81,6 +78,7 @@ public function loadConfiguration()
8178
->addSetup('setTempDirectory', array($this->tempDir))
8279
->addSetup('setAutoRefresh', array($this->debugMode))
8380
->addSetup('setContentType', array($config['xhtml'] ? Latte\Compiler::CONTENT_XHTML : Latte\Compiler::CONTENT_HTML))
81+
->addSetup('Nette\Utils\Html::$xhtml = ?;', array((bool) $config['xhtml']))
8482
->setAutowired(FALSE);
8583

8684
foreach ($config['macros'] as $macro) {
@@ -101,14 +99,6 @@ public function loadConfiguration()
10199
}
102100

103101

104-
public function afterCompile(Nette\PhpGenerator\ClassType $class)
105-
{
106-
if ($this->xhtml) {
107-
$class->methods['initialize']->addBody('Nette\Utils\Html::$xhtml = TRUE;');
108-
}
109-
}
110-
111-
112102
/**
113103
* @param callable
114104
* @return void

0 commit comments

Comments
 (0)