Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Find a way to set language context without creating user.
Code need to be updated:
$user_config_context = config_context_enter('Drupal\user\UserConfigContext');
$account = new User(array('langcode' => $language->langcode), 'user');
$user_config_context->setAccount($account);
Comment | File | Size | Author |
---|---|---|---|
#1 | 20202347-context-change-1.patch | 936 bytes | vijaycs85 |
Comments
Comment #1
vijaycs85Checked few context related meta and tried adding LanguageConfigcontext. But doesn't look we would get it any time soon. So updating another option that fix saving context for now.
Once LanguagConfigContext landed, we can replace this.
Comment #2
YesCT CreditAttribution: YesCT commentedThis is the one we need eventually: #2020361: Create LanguageConfigContext to activate configuration overrides based on language
Comment #3
Gábor HojtsyVery tricky and clever hack :D Thanks, committed. We should really get #2020361: Create LanguageConfigContext to activate configuration overrides based on language land and remove this hack though :) Other modules reacting to a user context may react to this user in ways we did not intend. It will work temporarily in the meantime until then.
Comment #4
vijaycs85Added an issue to make the permanent fix #2022335: Use LanguageConfigContext instead of UserConfigContext work around once #2020361: Create LanguageConfigContext to activate configuration overrides based on language is in.
Comment #5.0
(not verified) CreditAttribution: commentedadding pointer to helper issue.