Skip to content
Snippets Groups Projects
Commit a0ba7aa7 authored by Yves Guide's avatar Yves Guide
Browse files

Issue #3475243

Check if node translation exist before loading it
parent ea1e7298
No related branches found
No related tags found
No related merge requests found
......@@ -107,10 +107,14 @@ function _menu_link_sync_get_source_nid($menu_link_id) {
*/
function _menu_link_sync_get_link_for_target_language($menu_link_id, $target_language) {
$nid = _menu_link_sync_get_source_nid($menu_link_id);
if ($nid !== FALSE) {
$node = Node::load($nid);
/** @var \Drupal\menu_link\Plugin\Field\FieldType\MenuLinkItem $link */
return $node->getTranslation($target_language)->get('field_menulink')[0];
if( $node->hasTranslation($target_language) ) {
/** @var \Drupal\menu_link\Plugin\Field\FieldType\MenuLinkItem $link */
return $node->getTranslation($target_language)->get('field_menulink')[0];
}
}
return FALSE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment