mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
changed the cache option to only accepts an explicit path to a cache directory or false
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
Backward incompatibilities:
|
||||
* The short notation of the `block` tag changed.
|
||||
|
||||
* changed the cache option to only accepts an explicit path to a cache directory or false
|
||||
* added a way to add token parsers, filters, and visitors without creating an extension
|
||||
* added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface
|
||||
* changed the generated code to match the new coding standards
|
||||
|
||||
@@ -85,16 +85,8 @@ The following options are available:
|
||||
* `base_template_class`: The base template class to use for generated
|
||||
templates (default to `Twig_Template`).
|
||||
|
||||
* `cache`: It can take three values:
|
||||
|
||||
* `null` (the default): Twig will create a sub-directory under the system
|
||||
temp directory to store the compiled templates (not recommended as
|
||||
templates from two projects with the same name will share the same cache if
|
||||
your projects share the same Twig source code).
|
||||
|
||||
* `false`: disable the compile cache altogether (not recommended).
|
||||
|
||||
* An absolute path where to store the compiled templates.
|
||||
* `cache`: An absolute path where to store the compiled templates, or false
|
||||
to disable caching (which is the default).
|
||||
|
||||
* `auto_reload`: When developing with Twig, it's useful to recompile the
|
||||
template whenever the source code changes. If you don't provide a value for
|
||||
|
||||
@@ -48,9 +48,7 @@ class Twig_Environment
|
||||
* templates (default to Twig_Template).
|
||||
*
|
||||
* * cache: Can be one of three values:
|
||||
* * null (the default): Twig will create a sub-directory under the system tmp directory
|
||||
* (not recommended as templates from two projects with the same name will share the cache)
|
||||
* * false: disable the compile cache altogether
|
||||
* * false: disable the compilation cache (default)
|
||||
* * An absolute path where to store the compiled templates
|
||||
*
|
||||
* * auto_reload: Whether to reload the template is the original source changed.
|
||||
@@ -73,7 +71,10 @@ class Twig_Environment
|
||||
$this->autoReload = isset($options['auto_reload']) ? (bool) $options['auto_reload'] : $this->debug;
|
||||
$this->extensions = array('core' => new Twig_Extension_Core());
|
||||
$this->runtimeInitialized = false;
|
||||
$this->setCache(isset($options['cache']) ? $options['cache'] : null);
|
||||
if (isset($options['cache']) && $options['cache'])
|
||||
{
|
||||
$this->setCache($options['cache']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBaseTemplateClass()
|
||||
@@ -118,9 +119,9 @@ class Twig_Environment
|
||||
|
||||
public function setCache($cache)
|
||||
{
|
||||
$this->cache = null === $cache ? sys_get_temp_dir().DIRECTORY_SEPARATOR.'twig_'.md5(dirname(__FILE__)) : $cache;
|
||||
$this->cache = $cache;
|
||||
|
||||
if (false !== $this->cache && !is_dir($this->cache)) {
|
||||
if ($this->cache && !is_dir($this->cache)) {
|
||||
mkdir($this->cache, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user