Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Factory.php

function Factory::getCacheDir

1 call to Factory::getCacheDir()
Factory::createConfig in vendor/composer/composer/src/Composer/Factory.php

File

vendor/composer/composer/src/Composer/Factory.php, line 99

Class

Factory
Creates a configured instance of composer.

Namespace

Composer

Code

protected static function getCacheDir(string $home) : string {
    $cacheDir = Platform::getEnv('COMPOSER_CACHE_DIR');
    if ($cacheDir) {
        return $cacheDir;
    }
    $homeEnv = Platform::getEnv('COMPOSER_HOME');
    if ($homeEnv) {
        return $homeEnv . '/cache';
    }
    if (Platform::isWindows()) {
        if ($cacheDir = Platform::getEnv('LOCALAPPDATA')) {
            $cacheDir .= '/Composer';
        }
        else {
            $cacheDir = $home . '/cache';
        }
        return rtrim(strtr($cacheDir, '\\', '/'), '/');
    }
    $userDir = self::getUserDir();
    if (PHP_OS === 'Darwin') {
        // Migrate existing cache dir in old location if present
        if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
            Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
        }
        return $userDir . '/Library/Caches/composer';
    }
    if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
        return $home . '/cache';
    }
    if (self::useXdg()) {
        $xdgCache = Platform::getEnv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
        return $xdgCache . '/composer';
    }
    return $home . '/cache';
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal