Added option to set cache file permissions.
This commit is contained in:
committed by
Justin Hileman
parent
042d537992
commit
197a2b6807
@@ -39,6 +39,7 @@ class Mustache_Engine
|
||||
private $helpers;
|
||||
private $escape;
|
||||
private $charset = 'UTF-8';
|
||||
private $cacheFilePerm = 0644;
|
||||
|
||||
/**
|
||||
* Mustache class constructor.
|
||||
@@ -76,6 +77,9 @@ class Mustache_Engine
|
||||
*
|
||||
* // character set for `htmlspecialchars`. Defaults to 'UTF-8'
|
||||
* 'charset' => 'ISO-8859-1',
|
||||
*
|
||||
* // permissions for cache files. Defaults to 0644
|
||||
* 'cache_file_perm' => 0666,
|
||||
* );
|
||||
*
|
||||
* @param array $options (default: array())
|
||||
@@ -117,6 +121,10 @@ class Mustache_Engine
|
||||
if (isset($options['charset'])) {
|
||||
$this->charset = $options['charset'];
|
||||
}
|
||||
|
||||
if (isset($options['cache_file_perm'])) {
|
||||
$this->cacheFilePerm = $options['cache_file_perm'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -580,7 +588,7 @@ class Mustache_Engine
|
||||
$tempFile = tempnam(dirname($fileName), basename($fileName));
|
||||
if (false !== @file_put_contents($tempFile, $source)) {
|
||||
if (@rename($tempFile, $fileName)) {
|
||||
chmod($fileName, 0644);
|
||||
chmod($fileName, $this->cacheFilePerm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user