bug fix MaterioDecoupledLanguageLinks

This commit is contained in:
Bachir Soussi Chiadmi 2022-02-07 11:19:46 +01:00
parent 9184283a17
commit 1634750ec5
1 changed files with 3 additions and 3 deletions

View File

@ -53,17 +53,17 @@ class MaterioDecoupledLanguageLinks extends ControllerBase {
// build the links
$url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
$languages = $this->languageManager->getNativeLanguages();
if (!$url_object) {
// if path does not exists
$data["error"] = "path {$path} is not valid";
$route_name = "<front>";
$route_parameters = null;
$route_parameters = array();
}else{
$route_name = $url_object->getRouteName();
$route_parameters = $url_object->getrouteParameters();
}
$languages = $this->languageManager->getNativeLanguages();
foreach ($languages as $key => $language) {
$url = Url::fromRoute($route_name, $route_parameters, ["language"=>$language]);
$links[$key] = [