mirror of
https://github.com/getgrav/grav.git
synced 2026-02-28 09:31:32 +01:00
Added support for relative paths in PageObject::getLevelListing() [#3110]
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
1. [](#improved)
|
||||
* Make it possible to use an absolute path when loading a blueprint
|
||||
* Make serialize methods final in `ContentBlock`, `AbstractFile`, `FormTrait`, `ObjectCollectionTrait` and `ObjectTrait`
|
||||
* Added support for relative paths in `PageObject::getLevelListing()` [#3110](https://github.com/getgrav/grav/issues/3110)
|
||||
1. [](#bugfix)
|
||||
* Fixed port issue with `system.custom_base_url`
|
||||
* Hide errors with `exif_read_data` in `ImageFile`
|
||||
|
||||
@@ -439,8 +439,26 @@ class PageObject extends FlexPageObject
|
||||
public function getLevelListing(array $options): array
|
||||
{
|
||||
$index = $this->getFlexDirectory()->getIndex();
|
||||
if (!is_callable([$index, 'getLevelListing'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return method_exists($index, 'getLevelListing') ? $index->getLevelListing($options) : [];
|
||||
// Deal with relative paths.
|
||||
$initial = $options['initial'] ?? null;
|
||||
$var = $initial ? 'leaf_route' : 'route';
|
||||
$route = $options[$var] ?? '';
|
||||
if ($route !== '' && !str_starts_with($route, '/')) {
|
||||
$filesystem = Filesystem::getInstance();
|
||||
|
||||
$route = "/{$this->getKey()}/{$route}";
|
||||
$route = $filesystem->normalize($route);
|
||||
|
||||
$options[$var] = $route;
|
||||
}
|
||||
|
||||
[$status, $message, $response,] = $index->getLevelListing($options);
|
||||
|
||||
return [$status, $message, $response, $options[$var] ?? null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user