private function makeCacheFilename($cachePath, $templatesRoot, $filename, $mkdir = false)
    {
        // If the template filename is relative (ie. not starting by / and not specifying a scheme)
        // then we first prefis it with the current working directory. And then we continue as if
        // absolute.
        if ( (substr($filename, 0, 1) != '/')  && ! parse_url($filename, PHP_URL_SCHEME)) {
            $filename = getcwd() . '/' . $filename;
        }

        $cacheFile = str_replace($templatesRoot, $cachePath . '/figs', $filename) . '.fig';
        if ($mkdir) {
            // Create the intermediary folders if not exist.
            $intermed = dirname($cacheFile);
            if (! file_exists($intermed)) {
                // In case of permission problems, or file already exists (and is not a directory),
                // the regular PHP warnings will be issued.
                mkdir($intermed, 0700, true);
            }
        }
        return $cacheFile;
    }
private function makeCacheFilename($cachePath, $templatesRoot, $filename, $mkdir = false)
    {
        // If the template filename is relative (ie. not starting by / and not specifying a scheme)
        // then we first prefis it with the current working directory. And then we continue as if
        // absolute.
        if ( (substr($filename, 0, 1) != '/')  && ! parse_url($filename, PHP_URL_SCHEME)) {
            $filename = getcwd() . '/' . $filename;
        }

        $cacheFile = str_replace($templatesRoot, $cachePath . '/figs', $filename) . '.fig';
        if ($mkdir) {
            // Create the intermediary folders if not exist.
            $intermed = dirname($cacheFile);
            if (! file_exists($intermed)) {
                // In case of permission problems, or file already exists (and is not a directory),
                // the regular PHP warnings will be issued.
                mkdir($intermed, 0700, true);
            }
        }
        return $cacheFile;
    }
private function makeCacheFilename ( $ cachePath , $ templatesRoot , $ filename , $ mkdir = false ) { // If the template filename is relative (ie. not starting by / and not specifying a scheme) // then we first prefis it with the current working directory. And then we continue as if // absolute. if ( ( substr ( $ filename , 0 , 1 ) != '/' ) && ! parse_url ( $ filename , PHP_URL_SCHEME ) ) { $ filename = getcwd ( ) . '/' . $ filename ; } $ cacheFile = str_replace ( $ templatesRoot , $ cachePath . '/figs' , $ filename ) . '.fig' ; if ( $ mkdir ) { // Create the intermediary folders if not exist. $ intermed = dirname ( $ cacheFile ) ; if ( ! file_exists ( $ intermed ) ) { // In case of permission problems, or file already exists (and is not a directory), // the regular PHP warnings will be issued. mkdir ( $ intermed , 0700 , true ) ; } } return $ cacheFile ; }
The compiled file is at the same subfolder location as the source file,
relative to the templatesRoot directory, but under the tempPath directory.
In other words, tempPath and templatesRoot correspond together.

Example: if  cachePath is      /tmp/figdice
and templatesRoot is  /var/www/html/app/templates
and filename is       /var/www/html/app/templates/sub/footer.html

then     cacheFile is          /tmp/figdice/figs/sub/footer.html.fig

CAUTION: Relative path for the initial template file, is converted to absolute
using the current working directory (the way file_get_contents works).

You can work with exotic files (non local filesystem) provided that they are specified
with full (valid) scheme. @see http://php.net/manual/en/function.parse-url.php
@param string $cachePath
@param string $templatesRoot
@param string $filename
@param bool $mkdir Whether to create the intermediate folder structure
@return string
The compiled file is at the same subfolder location as the source file relative to the templatesRoot directory but under the tempPath directory . In other words tempPath and templatesRoot correspond together .