getpathtranslation invalid path temporary workarround
This commit is contained in:
parent
30b2c9267b
commit
7e460b9764
|
@ -51,6 +51,14 @@ class MaterioDecoupledLanguageLinks extends ControllerBase {
|
||||||
|
|
||||||
// build the links
|
// build the links
|
||||||
$url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
|
$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_name = $url_object->getRouteName();
|
||||||
$route_parameters = $url_object->getrouteParameters();
|
$route_parameters = $url_object->getrouteParameters();
|
||||||
$languages = $this->languageManager->getNativeLanguages();
|
$languages = $this->languageManager->getNativeLanguages();
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -184,13 +184,17 @@ import { MA } from 'vuejs/api/ma-axios'
|
||||||
MA.post(`materio_decoupled/path_translation_links?`, params)
|
MA.post(`materio_decoupled/path_translation_links?`, params)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log('Path translations links', data)
|
console.log('Path translations links', data)
|
||||||
links.forEach((link, i) => {
|
if (data.error) {
|
||||||
console.log("language link",path , link)
|
console.warn("error get translation paths", data.error);
|
||||||
let hreflang = link.getAttribute('hreflang')
|
} else {
|
||||||
|
links.forEach((link, i) => {
|
||||||
|
console.log("language link",path , link)
|
||||||
|
let hreflang = link.getAttribute('hreflang')
|
||||||
|
|
||||||
link.setAttribute('href', data.links[hreflang].url)
|
link.setAttribute('href', data.links[hreflang].url)
|
||||||
link.innerHTML = data.links[hreflang].title
|
link.innerHTML = data.links[hreflang].title
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Path translations links', error)
|
console.warn('Path translations links', error)
|
||||||
|
|
Loading…
Reference in New Issue