Upgrade to 3.8.0

This commit is contained in:
Bastian Allgeier
2022-10-06 10:11:54 +02:00
parent a9ed4e45ca
commit 7d168aae58
332 changed files with 26337 additions and 21977 deletions

View File

@@ -86,11 +86,7 @@ class PagePicker extends Picker
return $this->parent();
}
if ($items = $this->items()) {
return $items->parent();
}
return null;
return $this->items()?->parent();
}
/**
@@ -101,14 +97,14 @@ class PagePicker extends Picker
* @param \Kirby\Cms\Site|\Kirby\Cms\Page|null
* @return array|null
*/
public function modelToArray($model = null): ?array
public function modelToArray($model = null): array|null
{
if ($model === null) {
return null;
}
// the selected model is the site. there's nothing above
if (is_a($model, 'Kirby\Cms\Site') === true) {
if ($model instanceof Site) {
return [
'id' => null,
'parent' => null,
@@ -200,13 +196,13 @@ class PagePicker extends Picker
// help mitigate some typical query usage issues
// by converting site and page objects to proper
// pages by returning their children
if (is_a($items, 'Kirby\Cms\Site') === true) {
$items = $items->children();
} elseif (is_a($items, 'Kirby\Cms\Page') === true) {
$items = $items->children();
} elseif (is_a($items, 'Kirby\Cms\Pages') === false) {
throw new InvalidArgumentException('Your query must return a set of pages');
}
$items = match (true) {
$items instanceof Site,
$items instanceof Page => $items->children(),
$items instanceof Pages => $items,
default => throw new InvalidArgumentException('Your query must return a set of pages')
};
return $this->itemsForQuery = $items;
}
@@ -238,11 +234,7 @@ class PagePicker extends Picker
public function start()
{
if (empty($this->options['query']) === false) {
if ($items = $this->itemsForQuery()) {
return $items->parent();
}
return $this->site;
return $this->itemsForQuery()?->parent() ?? $this->site;
}
return $this->site;