Update to Kirby 4.7.0

This commit is contained in:
Paul Nicoué 2025-04-21 18:57:21 +02:00
parent 02a9ab387c
commit ba25a9a198
509 changed files with 26604 additions and 14872 deletions

View file

@ -7,7 +7,7 @@ return [
/**
* Defines a custom format that is used when the field is saved
*/
'format' => function (string $format = null) {
'format' => function (string|null $format = null) {
return $format;
}
],

View file

@ -12,7 +12,7 @@ return [
},
/**
* Layout size for cards: `tiny`, `small`, `medium`, `large` or `huge`
* Layout size for cards: `tiny`, `small`, `medium`, `large`, `huge`, `full`
*/
'size' => function (string $size = 'auto') {
return $size;

View file

@ -36,7 +36,7 @@ return [
},
'sanitizeOption' => function ($value) {
$options = array_column($this->options(), 'value');
return in_array($value, $options, true) === true ? $value : null;
return in_array($value, $options) === true ? $value : null;
},
'sanitizeOptions' => function ($values) {
$options = array_column($this->options(), 'value');

View file

@ -2,6 +2,7 @@
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\Str;
use Kirby\Uuid\Uuids;
return [
'props' => [
@ -22,7 +23,7 @@ return [
/**
* Info text for each item
*/
'info' => function (string $info = null) {
'info' => function (string|null $info = null) {
return $info;
},
@ -36,14 +37,14 @@ return [
/**
* The minimum number of required selected
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* The maximum number of allowed selected
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
@ -57,7 +58,7 @@ return [
/**
* Query for the items to be included in the picker
*/
'query' => function (string $query = null) {
'query' => function (string|null $query = null) {
return $query;
},
@ -75,13 +76,17 @@ return [
* @param string $store 'uuid'|'id'
*/
'store' => function (string $store = 'uuid') {
return Str::lower($store);
// fall back to ID, if UUIDs globally disabled
return match (Uuids::enabled()) {
false => 'id',
default => Str::lower($store)
};
},
/**
* Main text for each item
*/
'text' => function (string $text = null) {
'text' => function (string|null $text = null) {
return $text;
},
],

View file

@ -3,6 +3,7 @@
use Kirby\Cms\Api;
use Kirby\Cms\File;
use Kirby\Exception\Exception;
use Kirby\Exception\InvalidArgumentException;
return [
'props' => [
@ -22,18 +23,27 @@ return [
$uploads = [];
}
$template = $uploads['template'] ?? null;
$uploads['accept'] = '*';
if ($preview = $this->image) {
$uploads['preview'] = $preview;
}
if ($template = $uploads['template'] ?? null) {
// get parent object for upload target
$parent = $this->uploadParent($uploads['parent'] ?? null);
if ($parent === null) {
throw new InvalidArgumentException('"' . $uploads['parent'] . '" could not be resolved as a valid parent for the upload');
}
if ($template) {
$file = new File([
'filename' => 'tmp',
'parent' => $this->model(),
'parent' => $parent,
'template' => $template
]);
$uploads['accept'] = $file->blueprint()->acceptMime();
} else {
$uploads['accept'] = '*';
$uploads['accept'] = $file->blueprint()->acceptAttribute();
}
return $uploads;
@ -45,15 +55,7 @@ return [
throw new Exception('Uploads are disabled for this field');
}
if ($parentQuery = ($params['parent'] ?? null)) {
$parent = $this->model()->query($parentQuery);
} else {
$parent = $this->model();
}
if ($parent instanceof File) {
$parent = $parent->parent();
}
$parent = $this->uploadParent($params['parent'] ?? null);
return $api->upload(function ($source, $filename) use ($parent, $params, $map) {
$props = [
@ -71,6 +73,19 @@ return [
return $map($file, $parent);
});
},
'uploadParent' => function (string|null $parentQuery = null) {
$parent = $this->model();
if ($parentQuery) {
$parent = $parent->query($parentQuery);
}
if ($parent instanceof File) {
$parent = $parent->parent();
}
return $parent;
}
]
];