Further improve defined paths #3297

This commit is contained in:
Matias Griese
2021-04-13 11:55:18 +03:00
parent 16dab2c9f1
commit 75c63704f6
8 changed files with 22 additions and 22 deletions

View File

@@ -57,13 +57,13 @@ if (!defined('GRAV_BACKUP_PATH')) {
}
unset($path);
define('USER_PATH', GRAV_USER_PATH . DS);
define('CACHE_PATH', GRAV_CACHE_PATH . DS);
define('ROOT_DIR', GRAV_ROOT . DS);
define('USER_DIR', GRAV_WEBROOT . '/' . USER_PATH);
define('CACHE_DIR', (!str_starts_with(CACHE_PATH, '/') ? ROOT_DIR : '') . CACHE_PATH);
define('USER_DIR', GRAV_WEBROOT . '/' . USER_PATH . '/');
define('CACHE_DIR', (!str_starts_with(GRAV_CACHE_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_CACHE_PATH . '/');
// DEPRECATED: Do not use!
define('CACHE_PATH', GRAV_CACHE_PATH . DS);
define('USER_PATH', GRAV_USER_PATH . DS);
define('ROOT_DIR', GRAV_ROOT . DS);
define('ASSETS_DIR', GRAV_WEBROOT . '/assets/');
define('IMAGES_DIR', GRAV_WEBROOT . '/images/');
define('ACCOUNTS_DIR', USER_DIR . 'accounts/');
@@ -71,10 +71,10 @@ define('PAGES_DIR', USER_DIR .'pages/');
define('DATA_DIR', USER_DIR . 'data/');
define('PLUGINS_DIR', USER_DIR . 'plugins/');
define('THEMES_DIR', USER_DIR . 'themes/');
define('SYSTEM_DIR', (!str_starts_with(GRAV_SYSTEM_PATH, '/') ? ROOT_DIR : '') . GRAV_SYSTEM_PATH);
define('SYSTEM_DIR', (!str_starts_with(GRAV_SYSTEM_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_SYSTEM_PATH . '/');
define('LIB_DIR', SYSTEM_DIR . 'src/');
define('VENDOR_DIR', ROOT_DIR .'vendor/');
define('LOG_DIR', (!str_starts_with(GRAV_LOG_PATH, '/') ? ROOT_DIR : '') . GRAV_LOG_PATH . DS);
define('VENDOR_DIR', GRAV_ROOT . '/vendor/');
define('LOG_DIR', (!str_starts_with(GRAV_LOG_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_LOG_PATH . '/');
// END DEPRECATED
// Some extensions

View File

@@ -90,7 +90,7 @@ trait AssetUtilsTrait
}
$relative_dir = dirname($relative_path);
$link = ROOT_DIR . $relative_path;
$link = GRAV_ROOT . '/' . $relative_path;
}
// TODO: looks like this is not being used.

View File

@@ -252,7 +252,7 @@ trait TestingAssetsTrait
*/
public function addDir($directory, $pattern = self::DEFAULT_REGEX)
{
$root_dir = rtrim(ROOT_DIR, '/');
$root_dir = GRAV_ROOT;
// Check if $directory is a stream.
if (strpos($directory, '://')) {

View File

@@ -527,7 +527,7 @@ class GPM extends Iterator
$plugins = $this->getRepositoryPlugins();
if (null === $themes || null === $plugins) {
if (!is_writable(ROOT_DIR . '/cache/gpm')) {
if (!is_writable(GRAV_ROOT . '/cache/gpm')) {
throw new RuntimeException('The cache/gpm folder is not writable. Please check the folder permissions.');
}

View File

@@ -2095,7 +2095,7 @@ class Page implements PageInterface
*/
public function filePathClean()
{
return str_replace(ROOT_DIR, '', $this->filePath());
return str_replace(GRAV_ROOT . DS, '', $this->filePath());
}
/**

View File

@@ -211,7 +211,7 @@ class Twig
'assets' => $this->grav['assets'],
'taxonomy' => $this->grav['taxonomy'],
'browser' => $this->grav['browser'],
'base_dir' => rtrim(ROOT_DIR, '/'),
'base_dir' => GRAV_ROOT,
'home_url' => $pages->homeUrl($active_language),
'base_url' => $pages->baseUrl($active_language),
'base_url_absolute' => $pages->baseUrl($active_language, true),

View File

@@ -73,11 +73,11 @@ class InstallCommand extends GravCommand
$io = $this->getIO();
$dependencies_file = '.dependencies';
$this->destination = $input->getArgument('destination') ?: GRAV_ROOT;
$this->destination = $input->getArgument('destination') ?: GRAV_WEBROOT;
// fix trailing slash
$this->destination = rtrim($this->destination, DS) . DS;
$this->user_path = $this->destination . USER_PATH;
$this->user_path = $this->destination . GRAV_USER_PATH . DS;
if ($local_config_file = $this->loadLocalConfig()) {
$io->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
}

View File

@@ -62,7 +62,7 @@ foreach ($iterator as $directory) {
define('GANTRY_DEBUGGER', true);
define('GANTRY5_DEBUG', true);
define('GANTRY5_PLATFORM', 'grav');
define('GANTRY5_ROOT', rtrim(ROOT_DIR, '/'));
define('GANTRY5_ROOT', GRAV_ROOT);
define('GANTRY5_VERSION', '@version@');
define('GANTRY5_VERSION_DATE', '@versiondate@');
define('GANTRYADMIN_PATH', '');