Add support for extending blueprints with its parent (single level only)

This commit is contained in:
Matias Griese
2015-08-20 12:23:41 +03:00
parent 4a59b8ae43
commit c4cd355f5b

View File

@@ -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']));