Upgrade to 3.9.4

This commit is contained in:
Bastian Allgeier
2023-04-21 11:26:07 +02:00
parent cd495f054e
commit 38c8ba7e59
57 changed files with 4658 additions and 87 deletions

View File

@@ -536,29 +536,43 @@ trait PageActions
// create a temporary page object
$page = Page::factory($props);
// always create pages in the default language
if ($page->kirby()->multilang() === true) {
$languageCode = $page->kirby()->defaultLanguage()->code();
} else {
$languageCode = null;
}
// create a form for the page
$form = Form::for($page, ['values' => $props['content']]);
// use always default language to fill form with default values
$form = Form::for(
$page,
[
'language' => $languageCode,
'values' => $props['content']
]
);
// inject the content
$page = $page->clone(['content' => $form->strings(true)]);
// run the hooks and creation action
$page = $page->commit('create', ['page' => $page, 'input' => $props], function ($page, $props) {
// always create pages in the default language
if ($page->kirby()->multilang() === true) {
$languageCode = $page->kirby()->defaultLanguage()->code();
} else {
$languageCode = null;
$page = $page->commit(
'create',
[
'page' => $page,
'input' => $props
],
function ($page, $props) use ($languageCode) {
// write the content file
$page = $page->save($page->content()->toArray(), $languageCode);
// flush the parent cache to get children and drafts right
static::updateParentCollections($page, 'append');
return $page;
}
// write the content file
$page = $page->save($page->content()->toArray(), $languageCode);
// flush the parent cache to get children and drafts right
static::updateParentCollections($page, 'append');
return $page;
});
);
// publish the new page if a number is given
if (isset($props['num']) === true) {