From c4cd355f5b3802b8c1348bb205f5e7bc61b1b311 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 20 Aug 2015 12:23:41 +0300 Subject: [PATCH] Add support for extending blueprints with its parent (single level only) --- system/src/Grav/Common/Data/Blueprints.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Data/Blueprints.php b/system/src/Grav/Common/Data/Blueprints.php index 03db82263..629c089ec 100644 --- a/system/src/Grav/Common/Data/Blueprints.php +++ b/system/src/Grav/Common/Data/Blueprints.php @@ -45,7 +45,8 @@ class Blueprints $grav = static::getGrav(); /** @var UniformResourceLocator $locator */ $locator = $grav['locator']; - $filename = $locator($filename); + $parents = $locator->findResources($filename); + $filename = array_shift($parents); } } else { $filename = isset($this->search[$type]) ? $this->search[$type] : ''; @@ -73,6 +74,15 @@ class Blueprints if (!$extendType) { continue; + } elseif ($extendType === '@parent') { + $parentFile = array_shift($parents); + if (!$parentFile || !is_file($parentFile)) { + continue; + } + $blueprints = CompiledYamlFile::instance($parentFile)->content(); + $parent = new Blueprint($type.'-parent', $blueprints, $this); + $blueprint->extend($parent); + continue; } $context = is_string($extendConfig) || empty($extendConfig['context']) ? $this : new self(self::getGrav()['locator']->findResource($extendConfig['context']));