88namespace Nette \Bridges \CacheLatte ;
99
1010use Nette ;
11+ use Nette \Caching \Cache ;
1112use Latte ;
1213
1314
@@ -39,7 +40,7 @@ public function initialize()
3940 public function finalize ()
4041 {
4142 if ($ this ->used ) {
42- return ['Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this, $_g ); ' ];
43+ return ['Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this); ' ];
4344 }
4445 }
4546
@@ -56,7 +57,7 @@ public function nodeOpened(Latte\MacroNode $node)
5657 $ this ->used = TRUE ;
5758 $ node ->isEmpty = FALSE ;
5859 $ node ->openingCode = Latte \PhpWriter::using ($ node )
59- ->write ('<?php if (Nette\Bridges\CacheLatte\CacheMacro::createCache($netteCacheStorage, %var, $_g ->caches, %node.array?)) { ?> ' ,
60+ ->write ('<?php if (Nette\Bridges\CacheLatte\CacheMacro::createCache($netteCacheStorage, %var, $this->global ->caches, %node.array?)) { ?> ' ,
6061 Nette \Utils \Random::generate ()
6162 );
6263 }
@@ -68,7 +69,7 @@ public function nodeOpened(Latte\MacroNode $node)
6869 */
6970 public function nodeClosed (Latte \MacroNode $ node )
7071 {
71- $ node ->closingCode = '<?php $_l->tmp = array_pop($_g-> caches); if (!$_l->tmp instanceof stdClass) $_l->tmp ->end(); } ?> ' ;
72+ $ node ->closingCode = '<?php $_tmp = array_pop($this->global-> caches); if (!$_tmp instanceof stdClass) $_tmp ->end(); } ?> ' ;
7273 }
7374
7475
@@ -78,10 +79,10 @@ public function nodeClosed(Latte\MacroNode $node)
7879 /**
7980 * @return void
8081 */
81- public static function initRuntime (Latte \Template $ template, \ stdClass $ global )
82+ public static function initRuntime (Latte \Template $ template )
8283 {
83- if (!empty ($ global ->caches ) && $ template ->getEngine ()->getLoader () instanceof Latte \Loaders \FileLoader) {
84- end ($ global ->caches )->dependencies [Nette \Caching \Cache::FILES ][] = $ template ->getName ();
84+ if (!empty ($ template -> global ->caches ) && $ template ->getEngine ()->getLoader () instanceof Latte \Loaders \FileLoader) {
85+ end ($ template -> global ->caches )->dependencies [Nette \Caching \Cache::FILES ][] = $ template ->getName ();
8586 }
8687 }
8788
@@ -103,10 +104,10 @@ public static function createCache(Nette\Caching\IStorage $cacheStorage, $key, &
103104 $ key = array_merge ([$ key ], array_intersect_key ($ args , range (0 , count ($ args ))));
104105 }
105106 if ($ parents ) {
106- end ($ parents )->dependencies [Nette \ Caching \ Cache::ITEMS ][] = $ key ;
107+ end ($ parents )->dependencies [Cache::ITEMS ][] = $ key ;
107108 }
108109
109- $ cache = new Nette \ Caching \ Cache ($ cacheStorage , 'Nette.Templating.Cache ' );
110+ $ cache = new Cache ($ cacheStorage , 'Nette.Templating.Cache ' );
110111 if ($ helper = $ cache ->start ($ key )) {
111112 if (isset ($ args ['dependencies ' ])) {
112113 $ args += call_user_func ($ args ['dependencies ' ]);
@@ -115,8 +116,8 @@ public static function createCache(Nette\Caching\IStorage $cacheStorage, $key, &
115116 $ args ['expiration ' ] = $ args ['expire ' ]; // back compatibility
116117 }
117118 $ helper ->dependencies = [
118- Nette \ Caching \Cache ::TAGS => isset ($ args ['tags ' ]) ? $ args ['tags ' ] : NULL ,
119- Nette \ Caching \Cache ::EXPIRATION => isset ($ args ['expiration ' ]) ? $ args ['expiration ' ] : '+ 7 days ' ,
119+ $ cache ::TAGS => isset ($ args ['tags ' ]) ? $ args ['tags ' ] : NULL ,
120+ $ cache ::EXPIRATION => isset ($ args ['expiration ' ]) ? $ args ['expiration ' ] : '+ 7 days ' ,
120121 ];
121122 $ parents [] = $ helper ;
122123 }
0 commit comments