Back to FileStorage class

Method _getFilePath

protected bool|string
_getFilePath
(mixed $id, mixed $group)
Get a cache file path from an ID/group pair
Parameters
  • string $id The cache data ID
  • string $group The cache data group
Returns
  • bool|string The path to the data object or boolean false if the cache directory does not exist
Since
  • 1.7.0
Class: FileStorage
Project: Joomla

Method _getFilePath - Source code

/**
 * Get a cache file path from an ID/group pair
 *
 * @param   string  $id     The cache data ID
 * @param   string  $group  The cache data group
 *
 * @return  boolean|string  The path to the data object or boolean false if the cache directory does not exist
 *
 * @since   1.7.0
 */
protected function _getFilePath($id, $group)
{
    $name = $this->_getCacheId($id, $group);
    $dir = $this->_root . '/' . $group;
    // If the folder doesn't exist try to create it
    if (!is_dir($dir)) {
        // Make sure the index file is there
        $indexFile = $dir . '/index.html';
        @mkdir($dir) && file_put_contents($indexFile, '<!DOCTYPE html><title></title>');
    }
    // Make sure the folder exists
    if (!is_dir($dir)) {
        return false;
    }
    return $dir . '/' . $name . '.php';
}