protected function getCachePath($subdir = null, $create_if_not_exists = true)
    {
        $cache_base = $this->getCachePathFromWebRoot($subdir);

        $web_root = rtrim(THELIA_WEB_DIR, '/');

        $path = sprintf("%s/%s", $web_root, $cache_base);

        // Create directory (recursively) if it does not exists.
        if ($create_if_not_exists && !is_dir($path)) {
            if (!@mkdir($path, 0777, true)) {
                throw new \RuntimeException(sprintf("Failed to create %s file in cache directory", $path));
            }
        }

        // Check if path is valid, e.g. in the cache dir
        $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot()));

        if (strpos(realpath($path), $cache_base) !== 0) {
            throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir));
        }

        return $path;
    }
protected function getCachePath($subdir = null, $create_if_not_exists = true)
    {
        $cache_base = $this->getCachePathFromWebRoot($subdir);

        $web_root = rtrim(THELIA_WEB_DIR, '/');

        $path = sprintf("%s/%s", $web_root, $cache_base);

        // Create directory (recursively) if it does not exists.
        if ($create_if_not_exists && !is_dir($path)) {
            if (!@mkdir($path, 0777, true)) {
                throw new \RuntimeException(sprintf("Failed to create %s file in cache directory", $path));
            }
        }

        // Check if path is valid, e.g. in the cache dir
        $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot()));

        if (strpos(realpath($path), $cache_base) !== 0) {
            throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir));
        }

        return $path;
    }
protected function getCachePath ( $ subdir = null , $ create_if_not_exists = true ) { $ cache_base = $ this -> getCachePathFromWebRoot ( $ subdir ) ; $ web_root = rtrim ( THELIA_WEB_DIR , '/' ) ; $ path = sprintf ( "%s/%s" , $ web_root , $ cache_base ) ; // Create directory (recursively) if it does not exists. if ( $ create_if_not_exists && ! is_dir ( $ path ) ) { if ( ! @ mkdir ( $ path , 0777 , true ) ) { throw new \ RuntimeException ( sprintf ( "Failed to create %s file in cache directory" , $ path ) ) ; } } // Check if path is valid, e.g. in the cache dir $ cache_base = realpath ( sprintf ( "%s/%s" , $ web_root , $ this -> getCachePathFromWebRoot ( ) ) ) ; if ( strpos ( realpath ( $ path ) , $ cache_base ) !== 0 ) { throw new \ InvalidArgumentException ( sprintf ( "Invalid cache path %s, with subdirectory %s" , $ path , $ subdir ) ) ; } return $ path ; }
Return the absolute cache directory path

@param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
@param bool $create_if_not_exists create the directory if it is not found

@throws \RuntimeException         if cache directory cannot be created
@throws \InvalidArgumentException ii path is invalid, e.g. not in the cache dir

@return string the absolute cache directory path
Return the absolute cache directory path