* 1.3.0
+ * added cache reloading when auto_reload is true and an extension has been modified
* added the possibility to force the escaping of a string already marked as safe (instance of Twig_Markup)
* allowed empty templates to be used as traits
* added traits support for the "parent" function
if (false === $cache = $this->getCacheFilename($name)) {
eval('?>'.$this->compileSource($this->loader->getSource($name), $name));
} else {
- if (!is_file($cache) || ($this->isAutoReload() && !$this->loader->isFresh($name, filemtime($cache)))) {
+ if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) {
$this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $name));
}
return $this->loadedTemplates[$cls] = new $cls($this);
}
+ /**
+ * Returns true if the template is still fresh.
+ *
+ * Besides checking the loader for freshness information,
+ * this method also checks if the enabled extensions have
+ * not changed.
+ *
+ * @param string $name The template name
+ * @param timestamp $time The last modification time of the cached template
+ *
+ * @return Boolean true if the template is fresh, false otherwise
+ */
+ public function isTemplateFresh($name, $time)
+ {
+ foreach ($this->extensions as $extension) {
+ $r = new ReflectionObject($extension);
+ if (filemtime($r->getFileName()) > $time) {
+ return false;
+ }
+ }
+
+ return $this->loader->isFresh($name, $time);
+ }
+
public function resolveTemplate($names)
{
if (!is_array($names)) {