Skip to content

Commit

Permalink
Fix rebase stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Dec 12, 2024
1 parent c30fc27 commit f7aa00a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/Cms/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static function user(string|null $id = null): User|null
return $user;
}

throw new NotFoundException([
throw new NotFoundException(
key: 'user.notFound',
data: ['name' => $id]
);
Expand Down
113 changes: 57 additions & 56 deletions src/Cms/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Kirby\Exception\Exception;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Exception\NotFoundException;
use Kirby\Exception\PermissionException;
use Kirby\Filesystem\F;
use Kirby\Toolkit\Locale;
use Kirby\Toolkit\Str;
Expand Down Expand Up @@ -591,62 +592,62 @@ public function update(array|null $props = null): static
throw new PermissionException(key: 'language.update.permission');
}

$kirby = App::instance();

// don't change the language code
unset($props['code']);

// make sure the slug is nice and clean
$props['slug'] = Str::slug($props['slug'] ?? null);

// trigger before hook
$language = $kirby->apply(
'language.update:before',
[
'language' => $this,
'input' => $props
],
'language'
);

// updated language object
$language = $language->clone($props);

if (isset($props['translations']) === true) {
$language->translations = $props['translations'];
}

// validate the language rules after before hook was applied
LanguageRules::update($language, $this);

// if language just got promoted to be the new default language…
if ($this->isDefault() === false && $language->isDefault() === true) {
// convert the current default to a non-default language
$previous = $kirby->defaultLanguage()?->clone(['default' => false])->save();
$kirby->languages(false)->set($previous->code(), $previous);

foreach ($kirby->models() as $model) {
$model->storage()->touchLanguage($this);
}
}

$language = $language->save();

// make sure the language is also updated in the languages collection
$kirby->languages(false)->set($language->code(), $language);

// trigger after hook
$language = $kirby->apply(
'language.update:after',
[
'newLanguage' => $language,
'oldLanguage' => $this,
'input' => $props
],
'newLanguage'
);

return $language;
$kirby = App::instance();

// don't change the language code
unset($props['code']);

// make sure the slug is nice and clean
$props['slug'] = Str::slug($props['slug'] ?? null);

// trigger before hook
$language = $kirby->apply(
'language.update:before',
[
'language' => $this,
'input' => $props
],
'language'
);

// updated language object
$language = $language->clone($props);

if (isset($props['translations']) === true) {
$language->translations = $props['translations'];
}

// validate the language rules after before hook was applied
LanguageRules::update($language, $this);

// if language just got promoted to be the new default language…
if ($this->isDefault() === false && $language->isDefault() === true) {
// convert the current default to a non-default language
$previous = $kirby->defaultLanguage()?->clone(['default' => false])->save();
$kirby->languages(false)->set($previous->code(), $previous);

foreach ($kirby->models() as $model) {
$model->storage()->touchLanguage($this);
}
}

$language = $language->save();

// make sure the language is also updated in the languages collection
$kirby->languages(false)->set($language->code(), $language);

// trigger after hook
$language = $kirby->apply(
'language.update:after',
[
'newLanguage' => $language,
'oldLanguage' => $this,
'input' => $props
],
'newLanguage'
);

return $language;
}

/**
Expand Down

0 comments on commit f7aa00a

Please sign in to comment.