From c8e975a0151c74ea731dc709640310222d884297 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 2 Oct 2023 18:01:05 +0200 Subject: Update Mustache to 46286a1 --- Mustache/Source/FilesystemSource.php | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Mustache/Source/FilesystemSource.php (limited to 'Mustache/Source') diff --git a/Mustache/Source/FilesystemSource.php b/Mustache/Source/FilesystemSource.php new file mode 100644 index 00000000..270f584e --- /dev/null +++ b/Mustache/Source/FilesystemSource.php @@ -0,0 +1,77 @@ +fileName = $fileName; + $this->statProps = $statProps; + } + + /** + * Get the Source key (used to generate the compiled class name). + * + * @throws Mustache_Exception_RuntimeException when a source file cannot be read + * + * @return string + */ + public function getKey() + { + $chunks = array( + 'fileName' => $this->fileName, + ); + + if (!empty($this->statProps)) { + if (!isset($this->stat)) { + $this->stat = @stat($this->fileName); + } + + if ($this->stat === false) { + throw new Mustache_Exception_RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName)); + } + + foreach ($this->statProps as $prop) { + $chunks[$prop] = $this->stat[$prop]; + } + } + + return json_encode($chunks); + } + + /** + * Get the template Source. + * + * @return string + */ + public function getSource() + { + return file_get_contents($this->fileName); + } +} -- cgit v1.2.3-55-g7522