diff --git a/modules/oe_theme_helper/oe_theme_helper.module b/modules/oe_theme_helper/oe_theme_helper.module index a8f7470bc..2884e49d6 100644 --- a/modules/oe_theme_helper/oe_theme_helper.module +++ b/modules/oe_theme_helper/oe_theme_helper.module @@ -15,8 +15,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\image\Plugin\Field\FieldType\ImageItem; use Drupal\media\MediaInterface; use Drupal\oe_theme\ValueObject\ImageValueObject; -use Drupal\oe_theme_helper\LanguageSwitcherBuilderCallback; -use Drupal\Core\Block\BlockPluginInterface; /** * Implements hook_page_attachments(). @@ -309,17 +307,3 @@ function oe_theme_helper_form_entity_view_display_edit_form_alter(&$form, FormSt } } } - -/** - * Implements hook_block_view_BASE_BLOCK_ID_alter(). - */ -function oe_theme_helper_block_view_oe_theme_helper_page_header_alter(array &$build, BlockPluginInterface $block) { - // Add pre-render callback to build and inject the content language switcher - // within the page header block. - if (\Drupal::service('module_handler')->moduleExists('oe_multilingual')) { - $build['#pre_render'][] = [ - LanguageSwitcherBuilderCallback::class, - 'preRender', - ]; - } -} diff --git a/modules/oe_theme_helper/src/LanguageSwitcherBuilderCallback.php b/modules/oe_theme_helper/src/LanguageSwitcherBuilderCallback.php deleted file mode 100644 index 725d228bb..000000000 --- a/modules/oe_theme_helper/src/LanguageSwitcherBuilderCallback.php +++ /dev/null @@ -1,98 +0,0 @@ -addCacheContexts(['languages:language_content']); - - $entity = $multilingual_helper->getEntityFromCurrentRoute(); - // Bail out if there is no entity or if it's not a content entity. - if (!$entity || !$entity instanceof ContentEntityInterface) { - $cache->applyTo($build); - return $build; - } - - $cache->addCacheableDependency($entity); - $cache->applyTo($build); - - // Render the links only if the current entity translation language is not - // the same as the current site language. - /** @var \Drupal\Core\Entity\EntityInterface $translation */ - $translation = $multilingual_helper->getCurrentLanguageEntityTranslation($entity); - $current_language = $language_manager->getCurrentLanguage(); - if ($translation->language()->getId() === $current_language->getId()) { - return $build; - } - - $content = &$build['content']; - - $content['#language_switcher']['current'] = $translation->language()->getName(); - - /** @var \Drupal\Core\Language\LanguageInterface[] $languages */ - $languages = $language_manager->getNativeLanguages(); - $content['#language_switcher']['unavailable'] = $languages[$current_language->getId()]->getName(); - - // Normalize the links to an array of options suitable for the ECL - // "ecl-lang-select-pages" template. - $content['#language_switcher']['options'] = []; - foreach ($content_language_switcher_provider->getAvailableEntityLanguages($entity) as $language_code => $link) { - /** @var \Drupal\Core\Url $url */ - $url = $link['url']; - $href = $url - ->setOptions(['language' => $link['language']]) - ->setAbsolute(TRUE) - ->toString(); - - $content['#language_switcher']['options'][] = [ - 'href' => $href, - 'hreflang' => $language_code, - 'label' => $link['title'], - 'lang' => $language_code, - ]; - } - - $content['#language_switcher']['is_primary'] = TRUE; - - return $build; - } - -}