diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php index 69f61e597..f6407cadd 100644 --- a/system/src/Grav/Common/Page/Types.php +++ b/system/src/Grav/Common/Page/Types.php @@ -13,27 +13,24 @@ class Types implements \ArrayAccess, \Iterator, \Countable use ArrayAccess, Constructor, Iterator, Countable, Export; protected $items; + protected $systemBlueprints; public function register($type, $blueprint = null) { + if (!$blueprint && $this->systemBlueprints && isset($this->systemBlueprints[$type])) { + $useBlueprint = $this->systemBlueprints[$type]; + } else { + $useBlueprint = $blueprint; + } + if ($blueprint || empty($this->items[$type])) { - $this->items[$type] = $blueprint; + $this->items[$type] = $useBlueprint; } } public function scanBlueprints($path) { - $options = [ - 'compare' => 'Filename', - 'pattern' => '|\.yaml$|', - 'filters' => [ - 'key' => '|\.yaml$|' - ], - 'key' => 'SubPathName', - 'value' => 'PathName', - ]; - - $this->items = Folder::all($path, $options) + $this->items; + $this->items = $this->findBlueprints($path) + $this->items; } public function scanTemplates($path) @@ -48,6 +45,10 @@ class Types implements \ArrayAccess, \Iterator, \Countable 'recursive' => false ]; + if (!$this->systemBlueprints) { + $this->systemBlueprints = $this->findBlueprints('blueprints://pages'); + } + foreach (Folder::all($path, $options) as $type) { $this->register($type); } @@ -83,4 +84,19 @@ class Types implements \ArrayAccess, \Iterator, \Countable ksort($list); return $list; } + + private function findBlueprints($path) + { + $options = [ + 'compare' => 'Filename', + 'pattern' => '|\.yaml$|', + 'filters' => [ + 'key' => '|\.yaml$|' + ], + 'key' => 'SubPathName', + 'value' => 'PathName', + ]; + + return Folder::all($path, $options); + } }