Return the cache directory path relative to Web Root

@param  string $subdir the subdirectory related to cache base, or null to get the cache directory only.
@return string the cache directory path relative to Web Root
763885
protected function getCachePathFromWebRoot($subdir = null)
    {
        $cache_dir_from_web_root = $this->getCacheDirFromWebRoot();

        if ($subdir != null) {
            $safe_subdir = basename($subdir);

            $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir);
        } else {
            $path = $cache_dir_from_web_root;
        }

        // Check if path is valid, e.g. in the cache dir
        return $path;
    }
1192796
public function getPaths($sub = null)
    {
        $paths = [];

        foreach ($this->moduleLoader->getRegisteredModules() as $module) {
            if (is_dir($dir = $module->getPath($sub))) {
                // This path has a file, add it to the list
                $paths[$module->getName()] = $dir;
            }
        }

        return $paths;
    }
102510
private function cacheDirectory(): string
    {
        $cacheDirectory = (string) $this->cacheDirectory;

        if ('' === $cacheDirectory && false === \is_writable($cacheDirectory))
        {
            $cacheDirectory = \sys_get_temp_dir();
        }

        return \rtrim($cacheDirectory, '/');
    }
1029325
protected function getFilePath($filename, $subDir = null)
    {
        $directories = presenter()->assets->getFilePaths();
        
        foreach ($directories as $directory) {

            /**
             * Try with sub directory
             * find from public directory first then resource directory
             */
            if (isset($subDir)) {
                $subDir = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $subDir);

                if (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC,
                        $directory) . $subDir . $filename)) {
                    return $filePath;
                    break;
                } elseif (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC . 'assets' . DIRECTORY_SEPARATOR,
                        $directory) . $subDir . $filename)) {
                    return $filePath;
                    break;
                } elseif (is_file($filePath = $directory . $subDir . $filename)) {
                    return $filePath;
                    break;
                }
            }

            /**
             * Try without sub directory
             * find from public directory first then resource directory
             */
            if (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC, $directory) . $filename)) {
                return $filePath;
                break;
            } elseif (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC . 'assets' . DIRECTORY_SEPARATOR,
                    $directory) . $filename)) {
                return $filePath;
                break;
            } elseif (is_file($filePath = $directory . $filename)) {
                return $filePath;
                break;
            }
        }

        return false;
    }
590969
public function getDir($directory)
    {
        $directory = str_replace('/', DS, $directory);
        if (strpos($directory, $this->getBaseDir()) === false || !file_exists($directory)) {
            $directory = $this->getBaseDir() . DS . ltrim($directory, DS);
        }
        return $directory;
    }
278756
public function relative_file_root_path()
    {
        $subDirs = implode('/', $this->subDirs);
        if ($subDirs) {
            $subDirs .= '/';
        }
        return $subDirs . $this->fileRoot;
    }
52289
protected function getSubdomain( $subdomainId = null )
    {
        static $subdomains = array();
        $siteInfo = $this->getSiteInfo();

        if ( empty( $subdomainId ) || $siteInfo->getSubdomainId() == $subdomainId )
        {
            return $siteInfo->getSubdomain();
        }

        if ( ! isset( $subdomains[$subdomainId] ) )
        {
            /* @var $model \Grid\Core\Model\Uri\Model */
            $service    = $this->getServiceLocator();
            $model      = $service->get( 'Grid\Core\Model\SubDomain\Model' );
            $subdomain  = $model->find( $subdomainId );

            if ( empty( $subdomain ) )
            {
                $subdomains[$subdomainId] = '';
            }
            else
            {
                $subdomains[$subdomainId] = $subdomain->subdomain;
            }
        }

        return $subdomains[$subdomainId];
    }
857058
public function getActualFileDir($filename, $subDir = self::UPLOADER_SUB_DIR)
    {
        return $this->getPath(array($this->getMediaRootDir(), $subDir, $this->getFileDirPrefix($filename)));
    }
6763
private function getCachePath($cacheKey)
    {
        $folder = $this->cacheDir . substr($cacheKey, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheKey, 2,
                2) . DIRECTORY_SEPARATOR . substr($cacheKey, 4, 2) . DIRECTORY_SEPARATOR;
        if (!is_dir($folder)) {
            mkdir($folder, 0755, true);
        }

        return $folder . $cacheKey;
    }
1035318
public function getPath($sub = null)
    {
        if (is_array($sub)) {
            $sub = implode(DIRECTORY_SEPARATOR, $sub);
        }

        $path = $this->path;
        if (!is_null($sub)) {
            $path .= DIRECTORY_SEPARATOR.$sub;
        }

        return $path;
    }
1242763
protected function _getBasePath($plugin = false)
    {
        if ($plugin !== false) {
            return $this->_getPluginPath($plugin) . 'webroot' . DS;
        }

        return WWW_ROOT;
    }
938536
public static function calc_directory_for_subsite($subsite)
    {
        //$subsite = Subsite::currentSubsite();
        if ($subsite) {
            $title = $subsite->Title;
            $url = strtolower(singleton('SiteTree')->generateURLSegment($title));

            return $url;
        } else {
            return false;
        }
    }
828411
private function getCacheFilePath($key)
    {
        $hash = hash('sha256', $key);
        $subdir = substr($hash, 0, 2);
        $filename = substr($hash, 2);

        return $this->cacheDir
            . DIRECTORY_SEPARATOR
            . $subdir
            . DIRECTORY_SEPARATOR
            . $filename
        ;
    }
702908
public function setSubDir($subDir)
    {
        $this->sub_dir = $subDir;

        // ensure directory exists
        if (!mkdir($this->getUploadDir(), 0755, true))
        {
            throw new \Exception('Could not create directory '.$this->getUploadDir());
        }

        return $this;
    }
68643
public function getCacheDir()
    {
        if ($this->cacheDir === null) {
            $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR);
        }

        return $this->cacheDir;
    }
975290
protected function getCacheFilePath()
    {
        $hash = md5($this->filePath);
        $result = storage_path().'/cms/cache/';
        $result .= substr($hash, 0, 2).'/';
        $result .= substr($hash, 2, 2).'/';
        $result .= basename($this->filePath);
        $result .= '.php';

        return $result;
    }
841217
public static function getRelativePathFromID($fID)
    {
        $result = false;
        if ($fID) {
            $cache = Application::getFacadeApplication()->make('cache/request');
            /** @var \Concrete\Core\Cache\Cache $cache */
            if ($cache->isEnabled()) {
                $cacheItem = $cache->getItem('file_relative_path/' . $fID);
                if (!$cacheItem->isMiss()) {
                    return $cacheItem->get();
                }
            }
            $f = static::getByID($fID);
            if ($f !== null) {
                $result = $f->getRelativePath();
                if (isset($cacheItem)) {
                    $cacheItem->set($result)->save();
                }
            }
        }

        return $result;
    }