فهرست منبع

Added option to set cache file permissions.

jandreasn 13 سال پیش
والد
کامیت
197a2b6807
1فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 9 1
      src/Mustache/Engine.php

+ 9 - 1
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;
             }