From 742f6420e66d70dc90fbac3a31659df37b153814 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 15 Oct 2025 22:20:44 +0400 Subject: [PATCH 1/3] Move language configuration to a dedicated lang.php config --- composer.json | 2 +- helpers/functions.php | 6 +++--- shared/config/config.php | 12 ------------ shared/config/lang.php | 13 +++++++++++++ tests/_root/shared/config/lang.php | 13 +++++++++++++ 5 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 shared/config/lang.php create mode 100644 tests/_root/shared/config/lang.php diff --git a/composer.json b/composer.json index ec7fe4d..2e9dad3 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "type": "project", "require": { - "quantum/framework": "^2.9.8", + "quantum/framework": "dev-master", "fakerphp/faker": "^1.15", "bluemmb/faker-picsum-photos-provider": "^2.0", "doctrine/annotations": "^2.0", diff --git a/helpers/functions.php b/helpers/functions.php index 581c6b2..4930818 100644 --- a/helpers/functions.php +++ b/helpers/functions.php @@ -26,8 +26,8 @@ */ function url_with_lang(string $lang): string { - if (!in_array($lang, (array)config()->get('langs'))) { - $lang = config()->get('lang_default'); + if (!in_array($lang, (array)config()->get('lang.supported'))) { + $lang = config()->get('lang.default'); } if (trim(route_uri()) == '/') { @@ -40,7 +40,7 @@ function url_with_lang(string $lang): string $url = base_url(true); - $langSegmentIndex = config()->get('lang_segment'); + $langSegmentIndex = config()->get('lang.url_segment'); $uri = ''; diff --git a/shared/config/config.php b/shared/config/config.php index e29e80d..7be8066 100644 --- a/shared/config/config.php +++ b/shared/config/config.php @@ -38,18 +38,6 @@ */ 'app_key' => env('APP_KEY'), - /** - * --------------------------------------------------------- - * Language - * --------------------------------------------------------- - * - * Possible languages and project default language. - */ - 'multilang' => true, - 'langs' => ['en', 'ru', 'am'], - 'lang_default' => 'en', - 'lang_segment' => 1, - /** * --------------------------------------------------------- * Error handling diff --git a/shared/config/lang.php b/shared/config/lang.php new file mode 100644 index 0000000..abd9dc0 --- /dev/null +++ b/shared/config/lang.php @@ -0,0 +1,13 @@ + true, + 'supported' => ['en', 'ru', 'am'], + 'default' => 'en', + 'url_segment' => 1, +]; \ No newline at end of file diff --git a/tests/_root/shared/config/lang.php b/tests/_root/shared/config/lang.php new file mode 100644 index 0000000..abd9dc0 --- /dev/null +++ b/tests/_root/shared/config/lang.php @@ -0,0 +1,13 @@ + true, + 'supported' => ['en', 'ru', 'am'], + 'default' => 'en', + 'url_segment' => 1, +]; \ No newline at end of file From 2c6e02d0111ae3111160ac82f4dccca3f78f8500 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 15 Oct 2025 22:31:11 +0400 Subject: [PATCH 2/3] Removing lang configs from main config and one missing file --- tests/_root/helpers/functions.php | 8 ++++---- tests/_root/public/uploads/.gitkeep | 0 tests/_root/shared/config/config.php | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 tests/_root/public/uploads/.gitkeep diff --git a/tests/_root/helpers/functions.php b/tests/_root/helpers/functions.php index 581c6b2..c8888c8 100644 --- a/tests/_root/helpers/functions.php +++ b/tests/_root/helpers/functions.php @@ -26,8 +26,8 @@ */ function url_with_lang(string $lang): string { - if (!in_array($lang, (array)config()->get('langs'))) { - $lang = config()->get('lang_default'); + if (!in_array($lang, (array)config()->get('lang.supported'))) { + $lang = config()->get('lang.default'); } if (trim(route_uri()) == '/') { @@ -40,7 +40,7 @@ function url_with_lang(string $lang): string $url = base_url(true); - $langSegmentIndex = config()->get('lang_segment'); + $langSegmentIndex = config()->get('lang.url_segment'); $uri = ''; @@ -57,7 +57,7 @@ function url_with_lang(string $lang): string $url .= '/' . ($index == $langSegmentIndex ? $lang : $segment); } } - +dd($url); return $url; } diff --git a/tests/_root/public/uploads/.gitkeep b/tests/_root/public/uploads/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/_root/shared/config/config.php b/tests/_root/shared/config/config.php index 03fc74c..834d046 100644 --- a/tests/_root/shared/config/config.php +++ b/tests/_root/shared/config/config.php @@ -2,10 +2,6 @@ return [ 'app_key' => env('APP_KEY'), 'app_email' => 'app@quantumphp.io', - 'multilang' => true, - 'langs' => ['en', 'es', 'fr'], - 'lang_default' => 'en', - 'lang_segment' => 1, 'debug' => true, 'test' => 'Testing', 'otp_expires' => 2, From 966c237504433cec23fbaac935ae52d05784f824 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 15 Oct 2025 22:41:15 +0400 Subject: [PATCH 3/3] Adding ``.gitkeep` to `public/uploads` folder --- tests/Feature/modules/Api/AuthControllerTest.php | 2 -- tests/_root/public/uploads/.gitkeep | 0 2 files changed, 2 deletions(-) create mode 100644 tests/_root/public/uploads/.gitkeep diff --git a/tests/Feature/modules/Api/AuthControllerTest.php b/tests/Feature/modules/Api/AuthControllerTest.php index 1aaf7e2..75238a5 100644 --- a/tests/Feature/modules/Api/AuthControllerTest.php +++ b/tests/Feature/modules/Api/AuthControllerTest.php @@ -235,8 +235,6 @@ public function testModuleApiResendEndpointWithIncorrectOtpToken() $this->assertError($response, 'Incorrect credentials'); } - - protected function assertSuccess($response, string $message = null): void { $this->assertEquals('success', $response->get('status')); diff --git a/tests/_root/public/uploads/.gitkeep b/tests/_root/public/uploads/.gitkeep new file mode 100644 index 0000000..e69de29