Upgrade to 4.1.0

This commit is contained in:
Bastian Allgeier
2024-01-30 16:41:06 +01:00
parent 5c44c8fcfd
commit 9345fc1a0b
59 changed files with 678 additions and 274 deletions

View File

@@ -49,15 +49,26 @@ trait SiteActions
*/
public function changeTitle(
string $title,
string $languageCode = null
string|null $languageCode = null
): static {
$site = $this;
$title = trim($title);
$arguments = compact('site', 'title', 'languageCode');
// if the `$languageCode` argument is not set and is not the default language
// the `$languageCode` argument is sent as the current language
if (
$languageCode === null &&
$language = $this->kirby()->language()
) {
if ($language->isDefault() === false) {
$languageCode = $language->code();
}
}
return $this->commit('changeTitle', $arguments, function ($site, $title, $languageCode) {
return $site->save(['title' => $title], $languageCode);
});
$arguments = ['site' => $this, 'title' => trim($title), 'languageCode' => $languageCode];
return $this->commit(
'changeTitle',
$arguments,
fn ($site, $title, $languageCode) => $site->save(['title' => $title], $languageCode)
);
}
/**