From 197a2b68077c8045acdaaba51be0735b18bb26f9 Mon Sep 17 00:00:00 2001 From: jandreasn Date: Tue, 23 Oct 2012 09:28:40 +0200 Subject: [PATCH] Added option to set cache file permissions. --- src/Mustache/Engine.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 6e99943..a45f320 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -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; }