Skip to content
Snippets Groups Projects
Commit ca13c5b4 authored by Randal Vanheede's avatar Randal Vanheede
Browse files

Fix layout builder page wasn't working anymore

parent 7773d7d2
No related branches found
No related tags found
No related merge requests found
......@@ -15,27 +15,27 @@ class TranslationInheritance implements TranslationInheritanceInterface, Trusted
/**
* Shows a message on the layout builder page if the translation is inherited.
*/
public static function alterLayoutBuilder(): void {
public static function alterLayoutBuilder($element) {
$request = \Drupal::request();
if (!$entity_type_id = $request->attributes->get('entity_type_id')) {
return;
return $element;
}
$entity = $request->attributes->get($entity_type_id);
if (!$entity instanceof ContentEntityInterface) {
return;
return $element;
}
// The entity has to have the field for this to be applicable.
if (!$entity->hasField(static::FIELD_NAME)) {
return;
return $element;
}
// If this is the default translation, or this translation simply doesn't
// inherit from any other language, we instantly return.
if (!$entity->get(TranslationInheritanceInterface::FIELD_NAME)->source_language) {
return;
return $element;
}
// Translation inheritance can be recursive, make sure to get the actual
......@@ -51,6 +51,8 @@ To edit that content, please <a href=":link">click here</a>.', [
'@source' => $language->getId(),
':link' => $url->toString(),
]));
return $element;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment