Skip to content

Prevent global config override #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tanerkay
Copy link
Contributor

@tanerkay tanerkay commented Feb 13, 2024

It seems that when setting a scoped option, there are set*() calls on the global LocaleConfig, which override the global config.

So the following:

// assume originally set config is `'supported_locales' => ['en']`

// add a route with scoped config for English and Dutch
Route::localized(function () {
    Route::get('with-scoped-config', function () {
        return App::getLocale();
    })->middleware(['web', SetLocale::class]);
}, [
    'supported_locales' => ['en', 'nl'],
]);

// add a route without any config
Route::localized(function () {
    Route::get('without-scoped-config', function () {
        return App::getLocale();
    })->middleware(['web', SetLocale::class]);
});

would give the second route the same config as the first route.

also, calls afterwards to LocaleConfig::getSupportedLocales() and LocaleConfig::getOmittedLocale() would retain the value of the last route registration with a corresponding scoped config.

It seems the two lines can simply be removed, but might be worth checking if they had another purpose?

added test that failed before the changes to LocalizedRoutesRegistrar

@ivanvermeyen ivanvermeyen merged commit fff1b46 into codezero-be:master Feb 13, 2024
@ivanvermeyen
Copy link
Contributor

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants