getpathtranslation invalid path temporary workarround

This commit is contained in:
2021-03-08 14:41:22 +01:00
parent 30b2c9267b
commit 7e460b9764
3 changed files with 19 additions and 63 deletions

View File

@@ -51,6 +51,14 @@ class MaterioDecoupledLanguageLinks extends ControllerBase {
// build the links
$url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
// Call to a member function getRouteName() on bool in Drupal\materio_decoupled\Controller\MaterioDecoupledLanguageLinks->getPathTranslationLinks()
if (!$url_object) {
// if path does not exists rtuen an error
return new JsonResponse(array(
"links" = [],
"error" = "path {$path} is not valid"
));
}
$route_name = $url_object->getRouteName();
$route_parameters = $url_object->getrouteParameters();
$languages = $this->languageManager->getNativeLanguages();