Upgrade to 4.2.0

This commit is contained in:
Bastian Allgeier
2024-04-10 11:09:52 +02:00
parent 77d9337371
commit 7f4eb7509d
88 changed files with 1187 additions and 490 deletions

View File

@@ -71,7 +71,7 @@ class Api extends BaseApi
$field = Form::for($model)->field($name);
$fieldApi = $this->clone([
'data' => array_merge($this->data(), ['field' => $field]),
'data' => [...$this->data(), 'field' => $field],
'routes' => $field->api(),
]);
@@ -185,6 +185,30 @@ class Api extends BaseApi
return $pages->query($this->requestBody());
}
/**
* @throws \Kirby\Exception\NotFoundException if the section type cannot be found or the section cannot be loaded
*/
public function sectionApi(
ModelWithContent $model,
string $name,
string|null $path = null
): mixed {
if (!$section = $model->blueprint()?->section($name)) {
throw new NotFoundException('The section "' . $name . '" could not be found');
}
$sectionApi = $this->clone([
'data' => [...$this->data(), 'section' => $section],
'routes' => $section->api(),
]);
return $sectionApi->call(
$path,
$this->requestMethod(),
$this->requestData()
);
}
/**
* Returns the current Session instance
*