Skip to content

Commit

Permalink
Fix language conversion methods after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed May 22, 2024
1 parent 51fc2c2 commit 3df1b81
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Cms/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,18 @@ public static function create(array $props): static

$language->save();

// update the main languages collection in the app instance
$kirby->languages(false)->append($language->code(), $language);

if ($languages->count() === 0) {
foreach ($kirby->models() as $model) {
$model->storage()->convertLanguage(
'default',
$language->code()
$model->storage()->moveLanguage(
$kirby->defaultLanguage(),
$language
);
}
}

// update the main languages collection in the app instance
$kirby->languages(false)->append($language->code(), $language);

// trigger after hook
$kirby->trigger(
'language.create:after',
Expand Down Expand Up @@ -223,17 +223,17 @@ public function delete(): bool
throw new Exception('The language could not be deleted');
}

// get the original language collection and remove the current language
$kirby->languages(false)->remove($code);

foreach ($kirby->models() as $model) {
if ($this->isLast() === true) {
$model->storage()->convertLanguage($code, 'default');
$model->storage()->moveLanguage($this, $kirby->defaultLanguage());
} else {
$model->storage()->deleteLanguage($code);
$model->storage()->deleteLanguage($this);
}
}

// get the original language collection and remove the current language
$kirby->languages(false)->remove($code);

// trigger after hook
$kirby->trigger('language.delete:after', [
'language' => $this
Expand Down

0 comments on commit 3df1b81

Please sign in to comment.