mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 22:12:26 +02:00
add @config directive to get config values from blueprints
This commit is contained in:
@@ -33,6 +33,7 @@ form:
|
||||
type: checkboxes
|
||||
label: Process
|
||||
toggleable: true
|
||||
@config-default: system.pages.process
|
||||
default:
|
||||
markdown: true
|
||||
twig: false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Grav\Common\Data;
|
||||
|
||||
use Grav\Common\GravTrait;
|
||||
use RocketTheme\Toolbox\ArrayTraits\Export;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ use RocketTheme\Toolbox\ArrayTraits\Export;
|
||||
*/
|
||||
class Blueprint
|
||||
{
|
||||
use Export, DataMutatorTrait;
|
||||
use Export, DataMutatorTrait, GravTrait;
|
||||
|
||||
public $name;
|
||||
|
||||
@@ -372,6 +373,16 @@ class Blueprint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elseif (substr($name, 0, 8) == '@config-') {
|
||||
$property = substr($name, 8);
|
||||
$default = isset($field[$property]) ? $field[$property] : null;
|
||||
$config = self::getGrav()['config']->get($value, $default);
|
||||
|
||||
if (!is_null($config)) {
|
||||
$field[$property] = $config;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize predefined validation rule.
|
||||
|
||||
Reference in New Issue
Block a user