From 05e35261e4d83bdce48136328e0043f98405b5d1 Mon Sep 17 00:00:00 2001 From: maxicms Date: Thu, 6 Aug 2015 08:51:26 +0300 Subject: [PATCH 1/2] Add prefix compile ID for template file name --- src/Fenom.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Fenom.php b/src/Fenom.php index 7afcfaf..546abb5 100644 --- a/src/Fenom.php +++ b/src/Fenom.php @@ -115,6 +115,11 @@ class Fenom */ protected $_compile_dir = "/tmp"; + /** + * @var string compile prefix ID template + */ + protected $_compile_id = "default"; + /** * @var string[] compile directory for custom provider */ @@ -428,6 +433,18 @@ class Fenom return $this; } + /** + * Set compile prefix ID template + * + * @param string $id prefix ID to store compiled templates + * @return Fenom + */ + public function setCompileId($id) + { + $this->_compile_id = $id; + return $this; + } + /** * * @param callable $cb @@ -1020,10 +1037,10 @@ class Fenom foreach ($tpl as &$t) { $t = str_replace(":", "_", basename($t)); } - return implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash)); + return $this->_compile_id . '_' . implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash)); } else { $hash = $tpl . ":" . $options; - return sprintf("%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash)); + return sprintf($this->_compile_id . "_%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash)); } } From 0a8793fe7b22f3047eab44310ab83be40abbf6d0 Mon Sep 17 00:00:00 2001 From: maxicms Date: Thu, 6 Aug 2015 14:02:43 +0300 Subject: [PATCH 2/2] remove default prefix --- src/Fenom.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Fenom.php b/src/Fenom.php index 546abb5..7d7799f 100644 --- a/src/Fenom.php +++ b/src/Fenom.php @@ -118,7 +118,7 @@ class Fenom /** * @var string compile prefix ID template */ - protected $_compile_id = "default"; + protected $_compile_id; /** * @var string[] compile directory for custom provider @@ -1037,10 +1037,10 @@ class Fenom foreach ($tpl as &$t) { $t = str_replace(":", "_", basename($t)); } - return $this->_compile_id . '_' . implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash)); + return $this->_compile_id . implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash)); } else { $hash = $tpl . ":" . $options; - return sprintf($this->_compile_id . "_%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash)); + return sprintf($this->_compile_id . "%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash)); } }