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

View File

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

View File

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

View File

@@ -527,7 +527,7 @@ class GPM extends Iterator
$plugins = $this->getRepositoryPlugins(); $plugins = $this->getRepositoryPlugins();
if (null === $themes || null === $plugins) { 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.'); 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() 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'], 'assets' => $this->grav['assets'],
'taxonomy' => $this->grav['taxonomy'], 'taxonomy' => $this->grav['taxonomy'],
'browser' => $this->grav['browser'], 'browser' => $this->grav['browser'],
'base_dir' => rtrim(ROOT_DIR, '/'), 'base_dir' => GRAV_ROOT,
'home_url' => $pages->homeUrl($active_language), 'home_url' => $pages->homeUrl($active_language),
'base_url' => $pages->baseUrl($active_language), 'base_url' => $pages->baseUrl($active_language),
'base_url_absolute' => $pages->baseUrl($active_language, true), 'base_url_absolute' => $pages->baseUrl($active_language, true),

View File

@@ -73,11 +73,11 @@ class InstallCommand extends GravCommand
$io = $this->getIO(); $io = $this->getIO();
$dependencies_file = '.dependencies'; $dependencies_file = '.dependencies';
$this->destination = $input->getArgument('destination') ?: GRAV_ROOT; $this->destination = $input->getArgument('destination') ?: GRAV_WEBROOT;
// fix trailing slash // fix trailing slash
$this->destination = rtrim($this->destination, DS) . DS; $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()) { if ($local_config_file = $this->loadLocalConfig()) {
$io->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>'); $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('GANTRY_DEBUGGER', true);
define('GANTRY5_DEBUG', true); define('GANTRY5_DEBUG', true);
define('GANTRY5_PLATFORM', 'grav'); define('GANTRY5_PLATFORM', 'grav');
define('GANTRY5_ROOT', rtrim(ROOT_DIR, '/')); define('GANTRY5_ROOT', GRAV_ROOT);
define('GANTRY5_VERSION', '@version@'); define('GANTRY5_VERSION', '@version@');
define('GANTRY5_VERSION_DATE', '@versiondate@'); define('GANTRY5_VERSION_DATE', '@versiondate@');
define('GANTRYADMIN_PATH', ''); define('GANTRYADMIN_PATH', '');