diff --git a/src/Cms/Language.php b/src/Cms/Language.php index 67a06308e1..2bf67ac009 100644 --- a/src/Cms/Language.php +++ b/src/Cms/Language.php @@ -164,12 +164,6 @@ public static function create(array $props): static $language = new static($props); - if ($language->permissions()->can('create') === false) { - throw new PermissionException( - key: 'language.create.permission' - ); - } - // validate the new language LanguageRules::create($language); @@ -223,12 +217,6 @@ public static function create(array $props): static */ public function delete(): bool { - if ($this->permissions()->can('delete') === false) { - throw new PermissionException( - key: 'language.delete.permission' - ); - } - $kirby = App::instance(); $code = $this->code(); @@ -592,12 +580,6 @@ public function url(): string */ public function update(array|null $props = null): static { - if ($this->permissions()->can('update') === false) { - throw new PermissionException( - key: 'language.update.permission' - ); - } - $kirby = App::instance(); // don't change the language code diff --git a/src/Cms/LanguageRules.php b/src/Cms/LanguageRules.php index 1b5b9373c8..d948283a54 100644 --- a/src/Cms/LanguageRules.php +++ b/src/Cms/LanguageRules.php @@ -37,9 +37,7 @@ public static function create(Language $language): void ); } - $user = App::instance()->user(); - - if ($user?->role()->permissions()->for('languages', 'create') !== true) { + if ($language->permissions()->create() !== true) { throw new PermissionException( key: 'language.create.permission' ); @@ -60,9 +58,7 @@ public static function delete(Language $language): void ); } - $user = App::instance()->user(); - - if ($user?->role()->permissions()->for('languages', 'delete') !== true) { + if ($language->permissions()->delete() !== true) { throw new PermissionException( key: 'language.delete.permission' ); @@ -93,9 +89,7 @@ public static function update( ); } - $user = $kirby->user(); - - if ($user?->role()->permissions()->for('languages', 'update') !== true) { + if ($newLanguage->permissions()->update() !== true) { throw new PermissionException( key: 'language.update.permission' );