Add Pico::getVendorDir()
The vendor directory is the installation path of the `picocms/Pico` package. If `picocms/Pico` is the composer root package (as in pre-bundled releases), it should be identical to `Pico::getRootDir()`. However, if `picocms/Pico` was installed as composer dependency (e.g. by `picocms/pico-composer`), the vendor directory usually corresponds to something like `Pico::getRootDir() . "vendor/picocms/pico"`. The vendor directory is currently only used as a last resort to load Pico's sample contents.
This commit is contained in:
parent
cbb8ece579
commit
f52e3dc890
23
lib/Pico.php
23
lib/Pico.php
@ -74,6 +74,14 @@ class Pico
|
|||||||
*/
|
*/
|
||||||
protected $rootDir;
|
protected $rootDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vendor directory of this Pico instance
|
||||||
|
*
|
||||||
|
* @see Pico::getVendorDir()
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $vendorDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config directory of this Pico instance
|
* Config directory of this Pico instance
|
||||||
*
|
*
|
||||||
@ -262,6 +270,7 @@ 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->vendorDir = dirname(__DIR__) . '/';
|
||||||
$this->configDir = $this->getAbsolutePath($configDir);
|
$this->configDir = $this->getAbsolutePath($configDir);
|
||||||
$this->pluginsDir = $this->getAbsolutePath($pluginsDir);
|
$this->pluginsDir = $this->getAbsolutePath($pluginsDir);
|
||||||
$this->themesDir = $this->getAbsolutePath($themesDir);
|
$this->themesDir = $this->getAbsolutePath($themesDir);
|
||||||
@ -277,6 +286,16 @@ class Pico
|
|||||||
return $this->rootDir;
|
return $this->rootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the vendor directory of this Pico instance
|
||||||
|
*
|
||||||
|
* @return string vendor directory path
|
||||||
|
*/
|
||||||
|
public function getVendorDir()
|
||||||
|
{
|
||||||
|
return $this->vendorDir;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the config directory of this Pico instance
|
* Returns the config directory of this Pico instance
|
||||||
*
|
*
|
||||||
@ -744,8 +763,10 @@ class Pico
|
|||||||
// try to guess the content directory
|
// try to guess the content directory
|
||||||
if (is_dir($this->getRootDir() . 'content')) {
|
if (is_dir($this->getRootDir() . 'content')) {
|
||||||
$this->config['content_dir'] = $this->getRootDir() . 'content/';
|
$this->config['content_dir'] = $this->getRootDir() . 'content/';
|
||||||
} else {
|
} elseif (is_dir($this->getRootDir() . 'content-sample')) {
|
||||||
$this->config['content_dir'] = $this->getRootDir() . 'content-sample/';
|
$this->config['content_dir'] = $this->getRootDir() . 'content-sample/';
|
||||||
|
} else {
|
||||||
|
$this->config['content_dir'] = $this->getVendorDir() . 'content-sample/';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
|
$this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user