diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index c58e8e974..bb4503c98 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -73,6 +73,29 @@ class Blueprint extends BlueprintForm return $this; } + /** + * @param string $name + * @return array|mixed|null + * @since 1.7 + */ + public function getDefaultValue(string $name) + { + $path = explode('.', $name) ?: []; + $current = $this->getDefaults(); + + foreach ($path as $field) { + if (\is_object($current) && isset($current->{$field})) { + $current = $current->{$field}; + } elseif (\is_array($current) && isset($current[$field])) { + $current = $current[$field]; + } else { + return null; + } + } + + return $current; + } + /** * Get nested structure containing default values defined in the blueprints. *