Explicitly treat relative paths to be relative to Picos root dir
This tempers the BC break, we can now recommend to simply remove the ROOT_DIR part
This commit is contained in:
parent
fc7632b0ac
commit
cdef7a6324
@ -2,8 +2,8 @@
|
|||||||
require_once(__DIR__ . '/vendor/autoload.php');
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
$pico = new Pico(
|
$pico = new Pico(
|
||||||
__DIR__,
|
__DIR__,
|
||||||
__DIR__ . '/config/',
|
'config/',
|
||||||
__DIR__ . '/plugins/',
|
'plugins/',
|
||||||
__DIR__ . '/themes/'
|
'themes/'
|
||||||
);
|
);
|
||||||
echo $pico->run();
|
echo $pico->run();
|
||||||
|
24
lib/Pico.php
24
lib/Pico.php
@ -166,9 +166,9 @@ class Pico
|
|||||||
public function __construct($rootDir, $configDir, $pluginsDir, $themesDir)
|
public function __construct($rootDir, $configDir, $pluginsDir, $themesDir)
|
||||||
{
|
{
|
||||||
$this->rootDir = rtrim($rootDir, '/') . '/';
|
$this->rootDir = rtrim($rootDir, '/') . '/';
|
||||||
$this->configDir = rtrim($configDir, '/') . '/';
|
$this->configDir = $this->getAbsolutePath($configDir);
|
||||||
$this->pluginsDir = rtrim($pluginsDir, '/') . '/';
|
$this->pluginsDir = $this->getAbsolutePath($pluginsDir);
|
||||||
$this->themesDir = rtrim($themesDir, '/') . '/';
|
$this->themesDir = $this->getAbsolutePath($themesDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -399,7 +399,7 @@ class Pico
|
|||||||
$this->config['base_url'] = $this->getBaseUrl();
|
$this->config['base_url'] = $this->getBaseUrl();
|
||||||
}
|
}
|
||||||
if (!empty($this->config['content_dir'])) {
|
if (!empty($this->config['content_dir'])) {
|
||||||
$this->config['content_dir'] = rtrim($this->config['content_dir'], '/') . '/';
|
$this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
|
||||||
}
|
}
|
||||||
if (!empty($this->config['timezone'])) {
|
if (!empty($this->config['timezone'])) {
|
||||||
date_default_timezone_set($this->config['timezone']);
|
date_default_timezone_set($this->config['timezone']);
|
||||||
@ -1006,6 +1006,22 @@ class Pico
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a relative path absolute to Picos root dir
|
||||||
|
*
|
||||||
|
* This method also guarantees a trailing slash.
|
||||||
|
*
|
||||||
|
* @param string $path relative or absolute path
|
||||||
|
* @return string absolute path
|
||||||
|
*/
|
||||||
|
protected function getAbsolutePath($path)
|
||||||
|
{
|
||||||
|
if (substr($path, 0, 1) !== '/') {
|
||||||
|
$path = $this->getRootDir() . $path;
|
||||||
|
}
|
||||||
|
return rtrim($path, '/') . '/';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers events on plugins which implement {@link PicoPluginInterface}
|
* Triggers events on plugins which implement {@link PicoPluginInterface}
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user