Go\Instrument\ClassLoading\CachePathManager::getCacheDir PHP Méthode

getCacheDir() public méthode

Returns current cache directory for aspects, can be bull
public getCacheDir ( ) : null | string
Résultat null | string
    public function getCacheDir()
    {
        return $this->cacheDir;
    }

Usage Example

 /**
  * Save AOP proxy to the separate file anr returns the php source code for inclusion
  *
  * @param ReflectionClass $class Original class reflection
  * @param string|ClassProxy $child
  *
  * @return string
  */
 private function saveProxyToCache($class, $child)
 {
     static $cacheDirSuffix = '/_proxies/';
     $cacheDir = $this->cachePathManager->getCacheDir();
     // Without cache we should rewrite original file
     if (!$cacheDir) {
         return $child;
     }
     $cacheDir = $cacheDir . $cacheDirSuffix;
     $fileName = str_replace($this->options['appDir'] . DIRECTORY_SEPARATOR, '', $class->getFileName());
     $proxyFileName = $cacheDir . $fileName;
     $dirname = dirname($proxyFileName);
     if (!file_exists($dirname)) {
         mkdir($dirname, $this->options['cacheFileMode'], true);
     }
     $body = '<?php' . PHP_EOL;
     $namespace = $class->getNamespaceName();
     if ($namespace) {
         $body .= "namespace {$namespace};" . PHP_EOL . PHP_EOL;
     }
     $refNamespace = new ReflectionFileNamespace($class->getFileName(), $namespace);
     foreach ($refNamespace->getNamespaceAliases() as $fqdn => $alias) {
         $body .= "use {$fqdn} as {$alias};" . PHP_EOL;
     }
     $body .= $child;
     file_put_contents($proxyFileName, $body, LOCK_EX);
     // For cache files we don't want executable bits by default
     chmod($proxyFileName, $this->options['cacheFileMode'] & ~0111);
     return 'include_once AOP_CACHE_DIR . ' . var_export($cacheDirSuffix . $fileName, true) . ';' . PHP_EOL;
 }
All Usage Examples Of Go\Instrument\ClassLoading\CachePathManager::getCacheDir