Upgrade Kirby from 4.3.0 to 4.4.0
This commit is contained in:
parent
03905dbd83
commit
3bed01af75
293 changed files with 54254 additions and 187 deletions
|
|
@ -6,6 +6,7 @@ use Kirby\Data\Data;
|
|||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\LogicException;
|
||||
use Kirby\Exception\PermissionException;
|
||||
use Kirby\Filesystem\F;
|
||||
use Kirby\Toolkit\Locale;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
|
@ -145,8 +146,17 @@ class Language
|
|||
*/
|
||||
public static function create(array $props): static
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$user = $kirby->user();
|
||||
|
||||
if (
|
||||
$user === null ||
|
||||
$user->role()->permissions()->for('languages', 'create') === false
|
||||
) {
|
||||
throw new PermissionException(['key' => 'language.create.permission']);
|
||||
}
|
||||
|
||||
$props['code'] = Str::slug($props['code'] ?? null);
|
||||
$kirby = App::instance();
|
||||
$languages = $kirby->languages();
|
||||
|
||||
// make the first language the default language
|
||||
|
|
@ -204,8 +214,16 @@ class Language
|
|||
public function delete(): bool
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$user = $kirby->user();
|
||||
$code = $this->code();
|
||||
|
||||
if (
|
||||
$user === null ||
|
||||
$user->role()->permissions()->for('languages', 'delete') === false
|
||||
) {
|
||||
throw new PermissionException(['key' => 'language.delete.permission']);
|
||||
}
|
||||
|
||||
if ($this->isDeletable() === false) {
|
||||
throw new Exception('The language cannot be deleted');
|
||||
}
|
||||
|
|
@ -497,13 +515,22 @@ class Language
|
|||
*/
|
||||
public function update(array $props = null): static
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$user = $kirby->user();
|
||||
|
||||
if (
|
||||
$user === null ||
|
||||
$user->role()->permissions()->for('languages', 'update') === false
|
||||
) {
|
||||
throw new PermissionException(['key' => 'language.update.permission']);
|
||||
}
|
||||
|
||||
// don't change the language code
|
||||
unset($props['code']);
|
||||
|
||||
// make sure the slug is nice and clean
|
||||
$props['slug'] = Str::slug($props['slug'] ?? null);
|
||||
|
||||
$kirby = App::instance();
|
||||
$updated = $this->clone($props);
|
||||
|
||||
if (isset($props['translations']) === true) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue