mirror of
https://github.com/getgrav/grav.git
synced 2026-03-27 23:10:13 +01:00
Register all page types into blueprint://pages stream
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
* Added support for hiding form fields in blueprints by using dynamic property like `security@: admin.foobar`, `scope@: object` or `scope-ignore@: object` to any field
|
||||
1. [](#improved)
|
||||
* Doctrine filecache is now namespaced with prefix to support purging
|
||||
* Register all page types into `blueprint://pages` stream
|
||||
|
||||
# v1.5.2
|
||||
## mm/dd/2018
|
||||
|
||||
@@ -710,7 +710,6 @@ class Pages
|
||||
public static function getTypes()
|
||||
{
|
||||
if (!self::$types) {
|
||||
|
||||
$grav = Grav::instance();
|
||||
|
||||
$scanBlueprintsAndTemplates = function () use ($grav) {
|
||||
@@ -748,6 +747,18 @@ class Pages
|
||||
$scanBlueprintsAndTemplates();
|
||||
}
|
||||
|
||||
// Register custom paths to the locator.
|
||||
$locator = $grav['locator'];
|
||||
foreach (self::$types as $type => $paths) {
|
||||
foreach ($paths as $k => $path) {
|
||||
if (strpos($path, 'blueprints://') === 0) {
|
||||
unset($paths[$k]);
|
||||
}
|
||||
}
|
||||
if ($paths) {
|
||||
$locator->addPath('blueprints', "pages/$type.yaml", $paths);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$types;
|
||||
|
||||
@@ -33,7 +33,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
}
|
||||
|
||||
if (!$blueprint && $this->systemBlueprints) {
|
||||
$blueprint = isset($this->systemBlueprints[$type]) ? $this->systemBlueprints[$type] : $this->systemBlueprints['default'];
|
||||
$blueprint = $this->systemBlueprints[$type] ?? $this->systemBlueprints['default'];
|
||||
}
|
||||
|
||||
if ($blueprint) {
|
||||
@@ -43,7 +43,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
|
||||
public function scanBlueprints($uri)
|
||||
{
|
||||
if (!is_string($uri)) {
|
||||
if (!\is_string($uri)) {
|
||||
throw new \InvalidArgumentException('First parameter must be URI');
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
|
||||
public function scanTemplates($uri)
|
||||
{
|
||||
if (!is_string($uri)) {
|
||||
if (!\is_string($uri)) {
|
||||
throw new \InvalidArgumentException('First parameter must be URI');
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
if (strpos($name, '/')) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = ucfirst(strtr($name, '_', ' '));
|
||||
$list[$name] = ucfirst(str_replace('_', ' ', $name));
|
||||
}
|
||||
ksort($list);
|
||||
return $list;
|
||||
@@ -109,7 +109,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
|
||||
if (strpos($name, 'modular/') !== 0) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = trim(ucfirst(strtr(basename($name), '_', ' ')));
|
||||
$list[$name] = ucfirst(trim(str_replace('_', ' ', basename($name))));
|
||||
}
|
||||
ksort($list);
|
||||
return $list;
|
||||
|
||||
Reference in New Issue
Block a user