From cd31d41b07ed7791de729901897facc6cdaea5f3 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 22 Apr 2016 18:39:10 +0200 Subject: [PATCH] Use locator instead of CACHE_DIR --- system/src/Grav/Common/File/CompiledFile.php | 4 +++- system/src/Grav/Common/GPM/Installer.php | 4 +++- system/src/Grav/Console/Gpm/InstallCommand.php | 4 +++- system/src/Grav/Console/Gpm/SelfupgradeCommand.php | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php index 242548ac2..a7b6a8f26 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -1,6 +1,7 @@ raw === null && $this->content === null) { $key = md5($this->filename); - $file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php"); + $cache_dir = Grav::instance()['locator']->findResource('cache://', true); + $file = PhpFile::instance($cache_dir . "compiled/files/{$key}{$this->extension}.php"); $modified = $this->modified(); if (!$modified) { diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index 402fdd3c8..630f7226b 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -2,6 +2,7 @@ namespace Grav\Common\GPM; use Grav\Common\Filesystem\Folder; +use Grav\Common\Grav; class Installer { @@ -80,7 +81,8 @@ class Installer $zip = new \ZipArchive(); $archive = $zip->open($package); - $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid(); + $cache_dir = Grav::instance()['locator']->findResource('cache://', true); + $tmp = $cache_dir . 'tmp/Grav-' . uniqid(); if ($archive !== true) { self::$error = self::ZIP_OPEN_ERROR; diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 5903337e5..ae492d3d0 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -6,6 +6,7 @@ use Grav\Common\GPM\GPM; use Grav\Common\GPM\Installer; use Grav\Common\GPM\Response; use Grav\Common\GPM\Remote\Package as Package; +use Grav\Common\Grav; use Grav\Common\Utils; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; @@ -530,7 +531,8 @@ class InstallCommand extends ConsoleCommand */ private function downloadPackage($package) { - $this->tmp = CACHE_DIR . DS . 'tmp/Grav-' . uniqid(); + $cache_dir = Grav::instance()['locator']->findResource('cache://', true); + $this->tmp = $cache_dir . DS . 'tmp/Grav-' . uniqid(); $filename = $package->slug . basename($package->zipball_url); $output = Response::get($package->zipball_url, [], [$this, 'progress']); diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index 54c896202..7b6809b60 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -5,6 +5,7 @@ use Grav\Common\Filesystem\Folder; use Grav\Common\GPM\Installer; use Grav\Common\GPM\Response; use Grav\Common\GPM\Upgrader; +use Grav\Common\Grav; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputOption; @@ -173,7 +174,8 @@ class SelfupgradeCommand extends ConsoleCommand */ private function download($package) { - $this->tmp = CACHE_DIR . DS . 'tmp/Grav-' . uniqid(); + $cache_dir = Grav::instance()['locator']->findResource('cache://', true); + $this->tmp = $cache_dir . DS . 'tmp/Grav-' . uniqid(); $output = Response::get($package['download'], [], [$this, 'progress']); Folder::mkdir($this->tmp);