/**
  * @inheritdoc
  */
 protected function compile()
 {
     $currentPage = $this->getCurrentPage();
     $pageFinder = new PageFinder();
     if ($this->customLanguage) {
         $languageText = LanguageText::createFromOptionWizard($this->customLanguageText);
     } else {
         $languageText = new LanguageText();
     }
     $navigationFactory = new NavigationFactory($pageFinder, $languageText, $currentPage);
     $navigationItems = $navigationFactory->findNavigationItems($currentPage);
     // Do not generate module or header if there is none or only one link
     if (count($navigationItems) < 2) {
         return;
     }
     $templateItems = [];
     $headerLinks = new AlternateLinks();
     $queryParameters = $currentPage->languageQuery ? trimsplit(',', $currentPage->languageQuery) : [];
     $defaultUrlParameters = $this->createUrlParameterBag($queryParameters);
     foreach ($navigationItems as $item) {
         $urlParameters = clone $defaultUrlParameters;
         if (false === $this->executeHook($item, $urlParameters) || $this->hideNoFallback && !$item->isDirectFallback()) {
             continue;
         }
         if ($item->isDirectFallback()) {
             $headerLinks->addFromNavigationItem($item, $urlParameters);
         }
         // Remove active language from navigation but not from header links!
         if ($this->hideActiveLanguage && $item->isCurrentPage()) {
             continue;
         }
         $templateItems[] = $this->generateTemplateArray($item, $urlParameters);
     }
     $this->Template->items = $this->generateNavigationTemplate($templateItems);
     $GLOBALS['TL_HEAD'][] = $headerLinks->generate();
 }