From 65cc60b45a2184ec7dc5b1db5bd9dc6c94befc41 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Jun 2016 17:25:53 +0200 Subject: [PATCH] CacheMacro: compatibility with Latte master --- src/Bridges/CacheLatte/CacheMacro.php | 2 +- tests/Bridges.Latte/CacheMacro.cache.phpt | 2 +- .../expected/CacheMacro.cache.inc.phtml | 16 ++++++++++------ .../expected/CacheMacro.cache.phtml | 16 ++++++++++------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Bridges/CacheLatte/CacheMacro.php b/src/Bridges/CacheLatte/CacheMacro.php index 273303df..f2d60412 100644 --- a/src/Bridges/CacheLatte/CacheMacro.php +++ b/src/Bridges/CacheLatte/CacheMacro.php @@ -79,7 +79,7 @@ public function nodeClosed(Latte\MacroNode $node) /** * @return void */ - public static function initRuntime(Latte\Template $template) + public static function initRuntime(Latte\Runtime\Template $template) { if (!empty($template->global->cacheStack)) { $file = (new \ReflectionClass($template))->getFileName(); diff --git a/tests/Bridges.Latte/CacheMacro.cache.phpt b/tests/Bridges.Latte/CacheMacro.cache.phpt index 758e1659..ed751e54 100644 --- a/tests/Bridges.Latte/CacheMacro.cache.phpt +++ b/tests/Bridges.Latte/CacheMacro.cache.phpt @@ -32,5 +32,5 @@ Assert::matchFile( ); Assert::matchFile( __DIR__ . '/expected/CacheMacro.cache.inc.phtml', - file_get_contents($latte->getCacheFile(__DIR__ . '/templates/include.cache.latte')) + file_get_contents($latte->getCacheFile(__DIR__ . strtr('/templates/include.cache.latte', '/', DIRECTORY_SEPARATOR))) ); diff --git a/tests/Bridges.Latte/expected/CacheMacro.cache.inc.phtml b/tests/Bridges.Latte/expected/CacheMacro.cache.inc.phtml index 90200eed..0754afd1 100644 --- a/tests/Bridges.Latte/expected/CacheMacro.cache.inc.phtml +++ b/tests/Bridges.Latte/expected/CacheMacro.cache.inc.phtml @@ -1,15 +1,11 @@ global->cacheStorage, '%[\w]+%', $this->global->cacheStack)) { ?> @@ -18,7 +14,15 @@ class Template%a% extends Latte\Template $_tmp = array_pop($this->global->cacheStack); if (!$_tmp instanceof stdClass) $_tmp->end(); } +%A% + } + + function prepare() + { +%A% + Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this); +%A% } } diff --git a/tests/Bridges.Latte/expected/CacheMacro.cache.phtml b/tests/Bridges.Latte/expected/CacheMacro.cache.phtml index 3e2d2506..287838b9 100644 --- a/tests/Bridges.Latte/expected/CacheMacro.cache.phtml +++ b/tests/Bridges.Latte/expected/CacheMacro.cache.phtml @@ -1,15 +1,11 @@ global->cacheStack); if (!$_tmp instanceof stdClass) $_tmp->end(); } +%A% + } + + function prepare() + { +%A% + Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this); +%A% } }