From 178fa7002d7146128305c6c3c0e78a9f62124929 Mon Sep 17 00:00:00 2001 From: Ahmet Bora Date: Sat, 27 Jan 2024 19:41:11 +0300 Subject: [PATCH] Apply code reviews --- src/Cms/LanguageTranslations.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Cms/LanguageTranslations.php b/src/Cms/LanguageTranslations.php index 622f60bc2c..6ef7b8fb6f 100644 --- a/src/Cms/LanguageTranslations.php +++ b/src/Cms/LanguageTranslations.php @@ -19,14 +19,12 @@ */ class LanguageTranslations { - protected App $kirby; protected array $data; public function __construct( protected Language $language, self|array $translations = [] ) { - $this->kirby = App::instance(); $this->setTranslations($translations); } @@ -62,8 +60,9 @@ public function load(array $default = []): array */ public function save(array $translations = []): static { + $this->setTranslations($translations); + if ($root = $this->root()) { - $this->data = $translations; Data::write($root, $translations); } @@ -77,7 +76,7 @@ public function root(): string|null { $kirby = App::instance(); $root = $kirby->root('translations'); - $file = $root . '/' . $this->language->code() . '.php'; + $file = ($root ?? '') . '/' . $this->language->code() . '.php'; if ( $root !== null &&