Update Composer packages
This commit is contained in:
parent
0320235f6c
commit
a8b68fb61b
378 changed files with 28466 additions and 28852 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Blocks;
|
||||
use Kirby\Cms\Content;
|
||||
use Kirby\Cms\Field;
|
||||
use Kirby\Cms\Files;
|
||||
use Kirby\Cms\Html;
|
||||
|
@ -63,16 +64,16 @@ return function (App $app) {
|
|||
*/
|
||||
'toBlocks' => function (Field $field) {
|
||||
try {
|
||||
$blocks = Blocks::factory(Blocks::parse($field->value()), [
|
||||
'parent' => $field->parent(),
|
||||
$blocks = Blocks::parse($field->value());
|
||||
$blocks = Blocks::factory($blocks, [
|
||||
'parent' => $field->parent()
|
||||
]);
|
||||
|
||||
return $blocks->filter('isHidden', false);
|
||||
} catch (Throwable $e) {
|
||||
if ($field->parent() === null) {
|
||||
$message = 'Invalid blocks data for "' . $field->key() . '" field';
|
||||
} else {
|
||||
$message = 'Invalid blocks data for "' . $field->key() . '" field on parent "' . $field->parent()->title() . '"';
|
||||
} catch (Throwable) {
|
||||
$message = 'Invalid blocks data for "' . $field->key() . '" field';
|
||||
|
||||
if ($parent = $field->parent()) {
|
||||
$message .= ' on parent "' . $parent->title() . '"';
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException($message);
|
||||
|
@ -99,13 +100,10 @@ return function (App $app) {
|
|||
* @return array
|
||||
*/
|
||||
'toData' => function (Field $field, string $method = ',') {
|
||||
switch ($method) {
|
||||
case 'yaml':
|
||||
case 'json':
|
||||
return Data::decode($field->value, $method);
|
||||
default:
|
||||
return $field->split($method);
|
||||
}
|
||||
return match ($method) {
|
||||
'yaml', 'json' => Data::decode($field->value, $method),
|
||||
default => $field->split($method)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -222,6 +220,17 @@ return function (App $app) {
|
|||
return Html::a($href, $field->value, $attr ?? []);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse yaml data and convert it to a
|
||||
* content object
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @return \Kirby\Cms\Content
|
||||
*/
|
||||
'toObject' => function (Field $field) {
|
||||
return new Content($field->yaml(), $field->parent(), true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a page object from a page id in the field
|
||||
*
|
||||
|
@ -252,11 +261,11 @@ return function (App $app) {
|
|||
'toStructure' => function (Field $field) {
|
||||
try {
|
||||
return new Structure(Data::decode($field->value, 'yaml'), $field->parent());
|
||||
} catch (Exception $e) {
|
||||
if ($field->parent() === null) {
|
||||
$message = 'Invalid structure data for "' . $field->key() . '" field';
|
||||
} else {
|
||||
$message = 'Invalid structure data for "' . $field->key() . '" field on parent "' . $field->parent()->title() . '"';
|
||||
} catch (Exception) {
|
||||
$message = 'Invalid structure data for "' . $field->key() . '" field';
|
||||
|
||||
if ($parent = $field->parent()) {
|
||||
$message .= ' on parent "' . $parent->title() . '"';
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException($message);
|
||||
|
@ -341,7 +350,7 @@ return function (App $app) {
|
|||
* @param string $context Location of output (`html`, `attr`, `js`, `css`, `url` or `xml`)
|
||||
*/
|
||||
'escape' => function (Field $field, string $context = 'html') {
|
||||
$field->value = Str::esc($field->value, $context);
|
||||
$field->value = Str::esc($field->value ?? '', $context);
|
||||
return $field;
|
||||
},
|
||||
|
||||
|
@ -500,10 +509,11 @@ return function (App $app) {
|
|||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @param array $data
|
||||
* @param string $fallback Fallback for tokens in the template that cannot be replaced
|
||||
* @param string|null $fallback Fallback for tokens in the template that cannot be replaced
|
||||
* (`null` to keep the original token)
|
||||
* @return \Kirby\Cms\Field
|
||||
*/
|
||||
'replace' => function (Field $field, array $data = [], string $fallback = '') use ($app) {
|
||||
'replace' => function (Field $field, array $data = [], string|null $fallback = '') use ($app) {
|
||||
if ($parent = $field->parent()) {
|
||||
// never pass `null` as the $template to avoid the fallback to the model ID
|
||||
$field->value = $parent->toString($field->value ?? '', $data, $fallback);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue