mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Use stream wrapper in pages, plugins and themes
This commit is contained in:
@@ -5,6 +5,11 @@ schemes:
|
||||
- user/plugins
|
||||
- system/plugins
|
||||
|
||||
user:
|
||||
type: ReadOnlyStream
|
||||
paths:
|
||||
- user
|
||||
|
||||
# asset:
|
||||
# type: ReadOnlyStream
|
||||
# paths:
|
||||
|
||||
@@ -257,10 +257,7 @@ class Pages
|
||||
public function blueprints($type)
|
||||
{
|
||||
if (!isset($this->blueprints)) {
|
||||
/** @var Config $config */
|
||||
$config = $this->grav['config'];
|
||||
|
||||
$this->blueprints = new Data\Blueprints(THEMES_DIR . $config->get('system.pages.theme') . '/blueprints/');
|
||||
$this->blueprints = new Data\Blueprints('theme://blueprints/');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -314,12 +311,7 @@ class Pages
|
||||
*/
|
||||
static public function types()
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
/** @var Config $config */
|
||||
$config = $grav['config'];
|
||||
|
||||
$blueprints = new Data\Blueprints(THEMES_DIR . $config->get('system.pages.theme') . '/blueprints/');
|
||||
$blueprints = new Data\Blueprints('theme://blueprints/');
|
||||
|
||||
return $blueprints->types();
|
||||
}
|
||||
|
||||
@@ -101,18 +101,18 @@ class Plugins extends Iterator
|
||||
return $list;
|
||||
}
|
||||
|
||||
static public function get($type)
|
||||
static public function get($name)
|
||||
{
|
||||
$blueprints = new Data\Blueprints('plugin://' . $type);
|
||||
$blueprints = new Data\Blueprints("plugin://{$name}");
|
||||
$blueprint = $blueprints->get('blueprints');
|
||||
$blueprint->name = $type;
|
||||
$blueprint->name = $name;
|
||||
|
||||
// Load default configuration.
|
||||
$file = File\Yaml::instance('plugin://' . "{$type}/{$type}" . YAML_EXT);
|
||||
$file = File\Yaml::instance("plugin://{$name}/{$name}.yaml");
|
||||
$obj = new Data\Data($file->content(), $blueprint);
|
||||
|
||||
// Override with user configuration.
|
||||
$file = File\Yaml::instance('plugin://' . "config/plugins/{$type}" . YAML_EXT);
|
||||
$file = File\Yaml::instance("user://config/plugins/{$name}.yaml");
|
||||
$obj->merge($file->content());
|
||||
|
||||
// Save configuration always to user/config.
|
||||
|
||||
@@ -49,33 +49,33 @@ class Themes
|
||||
/**
|
||||
* Get theme or throw exception if it cannot be found.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $name
|
||||
* @return Data\Data
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function get($type)
|
||||
public function get($name)
|
||||
{
|
||||
if (!$type) {
|
||||
if (!$name) {
|
||||
throw new \RuntimeException('Theme name not provided.');
|
||||
}
|
||||
|
||||
$blueprints = new Data\Blueprints(THEMES_DIR . $type);
|
||||
$blueprints = new Data\Blueprints("theme://{$name}");
|
||||
$blueprint = $blueprints->get('blueprints');
|
||||
$blueprint->name = $type;
|
||||
$blueprint->name = $name;
|
||||
|
||||
// Find thumbnail.
|
||||
$thumb = THEMES_DIR . "{$type}/thumbnail.jpg";
|
||||
$thumb = THEMES_DIR . "{$name}/thumbnail.jpg";
|
||||
if (file_exists($thumb)) {
|
||||
// TODO: use real URL with base path.
|
||||
$blueprint->set('thumbnail', "/user/themes/{$type}/thumbnail.jpg");
|
||||
$blueprint->set('thumbnail', "/user/themes/{$name}/thumbnail.jpg");
|
||||
}
|
||||
|
||||
// Load default configuration.
|
||||
$file = File\Yaml::instance(THEMES_DIR . "{$type}/{$type}" . YAML_EXT);
|
||||
$file = File\Yaml::instance("theme://{$name}.yaml");
|
||||
$obj = new Data\Data($file->content(), $blueprint);
|
||||
|
||||
// Override with user configuration.
|
||||
$file = File\Yaml::instance(USER_DIR . "config/themes/{$type}" . YAML_EXT);
|
||||
$file = File\Yaml::instance("user://config/themes/{$name}.yaml");
|
||||
$obj->merge($file->content());
|
||||
|
||||
// Save configuration always to user/config.
|
||||
|
||||
Reference in New Issue
Block a user