Closed mankev closed 5 years ago
Think this just needs some sort of guard logic, and the actual unsetting is cause otherwise both languages show up English (no link) and French if on a english page and vice versa for French.
Added a guard and wrote a more apt description of what am doing ^_^
Thanks so much for patience :D
In Language Detection and Selection after deselecting Detection Method = URL (in order to use Browser language detection) there is a loss of language toggle on site pages and the following warning is displayed: "Warning: Attempt to modify property 'links' of non-object in Drupal\wxt_library\Plugin\Block\LanguageBlock->build() (line 154 of modules\custom\wxt_library\src\Plugin\Block\LanguageBlock.php). "
Release = 2.2.14 Theme = WxT Usability or Canada.ca (others not tested) php = 7.1
I did some debugging but I am not sure what it the code is supposed to do. (my comments)
Code snippet from affected code // Don't show current language in toggle. *(Is the loss of language toggle by design?) $toggle = FALSE; foreach ($config['language_toggle'] as $enabled) { if ($enabled === $wxt_active) { $toggle = TRUE; } } ($enable=0, $wxt-active = "theme-gcweb")****
When Detection Method = URL deselected $links= null (causes the error)
When Detection Method = URL selected (no error) {#6724 ▼ +"links": array:2 [▼ "en" => array:5 [▼ "url" => Url {#6455 ▶} "title" => "English" "language" => ConfigurableLanguage {#6444 ▶} "attributes" => array:1 [▶] "query" => [] ] "fr" => array:5 [▼ "url" => Url {#5341 ▶} "title" => "French" "language" => ConfigurableLanguage {#6527 ▶} "attributes" => array:1 [▶] "query" => [] ] ] +"method_id": "language-url" }
$config array:6 [▼ "id" => "wxt_language_block:language_interface" "label" => "WxT Language switcher" "provider" => "wxt_library" "label_display" => "visible" "wxt_theme" => false "language_toggle" => array:6 [▼ "theme-base" => "theme-base" "theme-ogpl" => "theme-ogpl" "theme-wet-boew" => 0 "theme-gcwu-fegc" => 0 "theme-gc-intranet" => 0 "theme-gcweb" => 0 ] ]